bune.city/_plugins/plugin.rb
2020-04-05 16:34:03 +10:00

27 lines
No EOL
512 B
Ruby

require "liquid"
require "jekyll"
require "nokogiri"
module Jekyll
module LynnesbianDotSpaceFilters
def summarise(excerpt)
doc = Nokogiri::HTML.fragment(excerpt) do |config|
config.noblanks
end
first_paragraph = doc.xpath(".//p")[0]
if first_paragraph.is_a?(NilClass) then
return "Couldn't generate a summary for this post."
else
return first_paragraph.text
end
end
def ansi_bg(code)
end
end
end
Liquid::Template.register_filter(Jekyll::LynnesbianDotSpaceFilters)