diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2018-03-07 23:14:41 +1100 |
---|---|---|
committer | blackst0ne <blackst0ne.ru@gmail.com> | 2018-03-07 23:14:41 +1100 |
commit | aa60db6cee8e285a39077c567c7f59fecbd0e0a3 (patch) | |
tree | 3436f1a3ab2ea99cc976a25f8e50f23872ba6cdd /lib/banzai/renderer | |
parent | b50756401746d936cfe3eea5e0c6d300ab0db0eb (diff) | |
download | gitlab-ce-aa60db6cee8e285a39077c567c7f59fecbd0e0a3.tar.gz |
Add CommonMark markdown enginereplace_redcarpet_with_cmark
Diffstat (limited to 'lib/banzai/renderer')
-rw-r--r-- | lib/banzai/renderer/common_mark/html.rb | 21 | ||||
-rw-r--r-- | lib/banzai/renderer/html.rb | 13 | ||||
-rw-r--r-- | lib/banzai/renderer/redcarpet/html.rb | 15 |
3 files changed, 36 insertions, 13 deletions
diff --git a/lib/banzai/renderer/common_mark/html.rb b/lib/banzai/renderer/common_mark/html.rb new file mode 100644 index 00000000000..c7a54629f31 --- /dev/null +++ b/lib/banzai/renderer/common_mark/html.rb @@ -0,0 +1,21 @@ +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>" \ + "<code#{lang_attr}>#{html_escape(code)}</code>" \ + "</pre>" + + out(result) + end + end + end + end + end +end diff --git a/lib/banzai/renderer/html.rb b/lib/banzai/renderer/html.rb deleted file mode 100644 index 252caa35947..00000000000 --- a/lib/banzai/renderer/html.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Banzai - module Renderer - class HTML < Redcarpet::Render::HTML - def block_code(code, lang) - lang_attr = lang ? %Q{ lang="#{lang}"} : '' - - "\n<pre>" \ - "<code#{lang_attr}>#{html_escape(code)}</code>" \ - "</pre>" - end - end - end -end diff --git a/lib/banzai/renderer/redcarpet/html.rb b/lib/banzai/renderer/redcarpet/html.rb new file mode 100644 index 00000000000..94df5d8b1e1 --- /dev/null +++ b/lib/banzai/renderer/redcarpet/html.rb @@ -0,0 +1,15 @@ +module Banzai + module Renderer + module Redcarpet + class HTML < ::Redcarpet::Render::HTML + def block_code(code, lang) + lang_attr = lang ? %Q{ lang="#{lang}"} : '' + + "\n<pre>" \ + "<code#{lang_attr}>#{html_escape(code)}</code>" \ + "</pre>" + end + end + end + end +end |