diff options
author | Brett Walker <bwalker@gitlab.com> | 2018-09-11 18:12:19 -0500 |
---|---|---|
committer | Brett Walker <bwalker@gitlab.com> | 2018-09-11 18:39:39 -0500 |
commit | 67cf5917e04f4afeaeb9e19a6154f0318f81e577 (patch) | |
tree | 2df6846254a4463b713f71054aa8cd5a641f2c9a /lib/banzai | |
parent | e91dc8f4badfdb4742d1662f34edd85f43fb317f (diff) | |
download | gitlab-ce-67cf5917e04f4afeaeb9e19a6154f0318f81e577.tar.gz |
'code_block' closer to original implementation
- utilize the 'out' method to output the 'fence_info',
which converts to utf8
- output 'sourcepos' again
Diffstat (limited to 'lib/banzai')
-rw-r--r-- | lib/banzai/renderer/common_mark/html.rb | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/banzai/renderer/common_mark/html.rb b/lib/banzai/renderer/common_mark/html.rb index 46b609c36b0..0b27316da1b 100644 --- a/lib/banzai/renderer/common_mark/html.rb +++ b/lib/banzai/renderer/common_mark/html.rb @@ -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 |