remove the <p> for lone images

This commit is contained in:
Yann Esposito 2012-12-20 13:21:47 +01:00
parent a87b00f835
commit 9bfa296091
2 changed files with 9 additions and 0 deletions

1
Rules
View file

@ -59,6 +59,7 @@ compile '/html/*' do
filter :erb # I'll try not to use ruby anymore inside content
filter :kramdown
# filter :math_repair # after kramdown
filter :fix_img
else
raise "Filter is not configured for #{item.identifier} in Rules file."
end

8
lib/fix_img.rb Normal file
View file

@ -0,0 +1,8 @@
class FixImage < Nanoc3::Filter
identifier :fix_img
def run(content, params={})
content.gsub(%r{<p>(<img[^>]*>)</p>}) do |m|
$1.to_s
end
end
end