rouge
rouge copied to clipboard
Escape and PHP lexer not working together
When using escape lexer with php lexer, it is not possible to highlight fragment of php code (if not starting with <?php
)
Rouge::Formatter.enable_escape!
formatter = Rouge::Formatters::HTML.new
escphp = Rouge::Lexers::Escape.new(lang: Rouge::Lexers::PHP.new(start_inline: true))
The string is not syntax highlighted by php, despite the start_inline
option specified
formatter.format(escphp.lex("$cfg[1]"))
# => "$cfg[1]"
Note that's working if prefixed with <?php
, but is not helpfull as a code fragment need to be highlighted
formatter.format(escphp.lex("<?php $cfg[1]"))
# => "<span class=\"cp\"><?php</span> <span class=\"nv\">$cfg</span><span class=\"p\">[</span><span class=\"mi\">1</span><span class=\"p\">]</span>"
Hi,
it acts like the inner lexer was not properly initialized, the start
block is not executed, it directly starts with state :root
.
Yep, looks like it needs a @lang.reset!
at the start of stream_tokens
.
This issue has been automatically marked as stale because it has not had any activity for more than a year. It will be closed if no additional activity occurs within the next 14 days. If you would like this issue to remain open, please reply and let us know if the issue is still reproducible.