Created
November 7, 2015 09:05
-
-
Save sumdog/99bf642024cc30f281bc to your computer and use it in GitHub Desktop.
Jekyll plug-in for stripping footnotes from kramdown encoded text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/