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/rouge/plugins | |
parent | b50756401746d936cfe3eea5e0c6d300ab0db0eb (diff) | |
download | gitlab-ce-aa60db6cee8e285a39077c567c7f59fecbd0e0a3.tar.gz |
Add CommonMark markdown enginereplace_redcarpet_with_cmark
Diffstat (limited to 'lib/rouge/plugins')
-rw-r--r-- | lib/rouge/plugins/common_mark.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/rouge/plugins/common_mark.rb b/lib/rouge/plugins/common_mark.rb new file mode 100644 index 00000000000..8f9de061124 --- /dev/null +++ b/lib/rouge/plugins/common_mark.rb @@ -0,0 +1,20 @@ +# A rouge plugin for CommonMark markdown engine. +# Used to highlight code generated by CommonMark. + +module Rouge + module Plugins + module CommonMark + def code_block(code, language) + lexer = Lexer.find_fancy(language, code) || Lexers::PlainText + + formatter = rouge_formatter(lexer) + formatter.format(lexer.lex(code)) + end + + # override this method for custom formatting behavior + def rouge_formatter(lexer) + Formatters::HTMLLegacy.new(css_class: "highlight #{lexer.tag}") + end + end + end +end |