diff options
Diffstat (limited to 'lib/banzai')
-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 |