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 end end Liquid::Template.register_filter(Jekyll::LynnesbianDotSpaceFilters)