diff options
author | Munken <mm.munk@gmail.com> | 2016-12-08 22:59:37 +0000 |
---|---|---|
committer | Munken <mm.munk@gmail.com> | 2016-12-08 22:59:37 +0000 |
commit | aa2c437fe05ea272e180527a848455599f9da916 (patch) | |
tree | 76d3adc760c6aa628f2730289b73daca1eb65a9a /lib | |
parent | 525c2a782e03afafdf9cf1948ab75e73092704fa (diff) | |
download | gitlab-ce-aa2c437fe05ea272e180527a848455599f9da916.tar.gz |
Hacked in Math Lexer
Diffstat (limited to 'lib')
-rw-r--r-- | lib/banzai/filter/syntax_highlight_filter.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/banzai/filter/syntax_highlight_filter.rb b/lib/banzai/filter/syntax_highlight_filter.rb index 026b81ac175..f6a813ac923 100644 --- a/lib/banzai/filter/syntax_highlight_filter.rb +++ b/lib/banzai/filter/syntax_highlight_filter.rb @@ -1,5 +1,29 @@ require 'rouge/plugins/redcarpet' +module Rouge + module Lexers + class Math < Lexer + title "Plain Text" + desc "A boring lexer that doesn't highlight anything" + + tag 'math' + aliases 'text' + filenames '*.txt' + mimetypes 'text/plain' + + default_options :token => 'Text' + + def token + @token ||= Token[option :token] + end + + def stream_tokens(string, &b) + yield self.token, string + end + end + end +end + module Banzai module Filter # HTML Filter to highlight fenced code blocks @@ -48,6 +72,9 @@ module Banzai end def lexer_for(language) + if language == 'math' + return Rouge::Lexers::Math.new + end (Rouge::Lexer.find(language) || Rouge::Lexers::PlainText).new end |