rouge icon indicating copy to clipboard operation
rouge copied to clipboard

Escape and PHP lexer not working together

Open sdalu opened this issue 3 years ago • 3 comments

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\">&lt;?php</span> <span class=\"nv\">$cfg</span><span class=\"p\">[</span><span class=\"mi\">1</span><span class=\"p\">]</span>"

sdalu avatar Mar 09 '21 10:03 sdalu

Hi,

it acts like the inner lexer was not properly initialized, the start block is not executed, it directly starts with state :root.

julp avatar Oct 25 '21 21:10 julp

Yep, looks like it needs a @lang.reset! at the start of stream_tokens.

jneen avatar Oct 25 '21 23:10 jneen

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.

stale[bot] avatar Nov 02 '22 04:11 stale[bot]