Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/rouge
diff options
context:
space:
mode:
authorblackst0ne <blackst0ne.ru@gmail.com>2018-03-07 15:14:41 +0300
committerblackst0ne <blackst0ne.ru@gmail.com>2018-03-07 15:14:41 +0300
commitaa60db6cee8e285a39077c567c7f59fecbd0e0a3 (patch)
tree3436f1a3ab2ea99cc976a25f8e50f23872ba6cdd /lib/rouge
parentb50756401746d936cfe3eea5e0c6d300ab0db0eb (diff)
Add CommonMark markdown engine
Diffstat (limited to 'lib/rouge')
-rw-r--r--lib/rouge/plugins/common_mark.rb20
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