Skip to content

Instantly share code, notes, and snippets.

@sumdog
Created November 7, 2015 09:05
Show Gist options
  • Save sumdog/99bf642024cc30f281bc to your computer and use it in GitHub Desktop.
Save sumdog/99bf642024cc30f281bc to your computer and use it in GitHub Desktop.
Jekyll plug-in for stripping footnotes from kramdown encoded text
require 'nokogiri'
module Jekyll
module StripFootnotesFilter
def strip_footnotes(raw)
doc = Nokogiri::HTML.fragment(raw.encode('UTF-8', :invalid => :replace, :undef => :replace, :replace => ''))
for block in ['div', 'sup', 'a'] do
doc.css(block).each do |ele|
ele.remove if (ele['class'] == 'footnotes' or ele['class'] == 'footnote')
end
end
doc.inner_html
end
end
end
Liquid::Template.register_filter(Jekyll::StripFootnotesFilter)
@sumdog
Copy link
Author

sumdog commented Nov 7, 2015

Plug-in for removing footnotes in kramdown encoded text in Jekyll. For full documentation and usage, see http://penguindreams.org/blog/removing-footnotes-from-excerpts-in-jekyll/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment