2018-03-07 12:14:41 +00:00
|
|
|
module Banzai
|
|
|
|
module Renderer
|
|
|
|
module CommonMark
|
|
|
|
class HTML < CommonMarker::HtmlRenderer
|
|
|
|
def code_block(node)
|
|
|
|
block do
|
|
|
|
code = node.string_content
|
|
|
|
lang = node.fence_info
|
|
|
|
lang_attr = lang.present? ? %Q{ lang="#{lang}"} : ''
|
|
|
|
result =
|
|
|
|
"<pre>" \
|
2018-04-17 09:39:11 +00:00
|
|
|
"<code#{lang_attr}>#{ERB::Util.html_escape(code)}</code>" \
|
2018-03-07 12:14:41 +00:00
|
|
|
"</pre>"
|
|
|
|
|
|
|
|
out(result)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|