Added code block normalization routing for import

This commit is contained in:
Sam Saffron
2014-06-06 10:34:21 +10:00
parent 544e7b999e
commit 05ca1e6e46
4 changed files with 37 additions and 0 deletions

12
lib/import/normalize.rb Normal file
View File

@ -0,0 +1,12 @@
# markdown normalizer to be used by importers
#
#
require 'htmlentities'
module Import::Normalize
def self.normalize_code_blocks(code, lang=nil)
coder = HTMLEntities.new
code.gsub(/<pre>\s*<code>\n?(.*?)\n?<\/code>\s*<\/pre>/m) {
"\n```#{lang}\n#{coder.decode($1)}\n```\n"
}
end
end