rouge-ruby / rouge

A pure Ruby code highlighter that is compatible with Pygments
https://rouge.jneen.net/
Other
3.3k stars 732 forks source link

Fix builtins missing keywords issue in Matlab #2007

Open tancnle opened 8 months ago

tancnle commented 8 months ago

Rendering MATLAB code on Rouge (https://rouge.jneen.net/v4.2.0/matlab/) causes exception.

2023-10-26T23:54:09Z app[e2865659b14968] lax [info]2023-10-26 23:54:09 - NameError - uninitialized constant Rouge::Lexers::Matlab:
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge/lexers/matlab/keywords.rb:11:in `<module:Lexers>'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge/lexers/matlab/keywords.rb:10:in `<module:Rouge>'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge/lexers/matlab/keywords.rb:9:in `<top (required)>'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge/lexers/matlab.rb:24:in `load'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge/lexers/matlab.rb:24:in `builtins'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge/lexers/matlab.rb:46:in `block (2 levels) in <class:Matlab>'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge/regex_lexer.rb:364:in `instance_exec'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge/regex_lexer.rb:364:in `block in step'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge/regex_lexer.rb:346:in `each'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge/regex_lexer.rb:346:in `step'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge/regex_lexer.rb:327:in `stream_tokens'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge/lexer.rb:480:in `continue_lex'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge/lexer.rb:470:in `lex'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge/formatter.rb:58:in `each'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge/formatter.rb:58:in `filter_escapes'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge/formatters/html.rb:20:in `each'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge/formatters/html.rb:20:in `stream'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge/formatter.rb:74:in `format'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge/formatter.rb:46:in `format'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/tmp/rouge/rouge-4.2.0/lib/rouge.rb:36:in `highlight'
2023-10-26T23:54:09Z app[e2865659b14968] lax [info]     /app/lib/demo.rb:21:in `result'
tancnle commented 7 months ago

@jneen Keen to hear your thoughts on this change.