Commit 67cf5917 authored by Brett Walker's avatar Brett Walker

'code_block' closer to original implementation

- utilize the 'out' method to output the 'fence_info',
  which converts to utf8
- output 'sourcepos' again
parent e91dc8f4
......@@ -4,15 +4,11 @@ module Banzai
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>" \
"<code#{lang_attr}>#{ERB::Util.html_escape(code)}</code>" \
"</pre>"
out(result)
out("<pre#{sourcepos(node)}><code")
out(' lang="', node.fence_info, '"') if node.fence_info.present?
out('>')
out(escape_html(node.string_content))
out('</code></pre>')
end
end
end
......
......@@ -40,6 +40,12 @@ describe Banzai::Filter::MarkdownFilter do
expect(result).to start_with("<pre><code>")
end
it 'works with utf8 chars in language' do
result = filter("```日\nsome code\n```")
expect(result).to start_with("<pre><code lang=\"\">")
end
end
context 'using Redcarpet' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment