rouge icon indicating copy to clipboard operation
rouge copied to clipboard

HTML Formatter Always Escapes

Open istana opened this issue 3 weeks ago • 0 comments

Describe the bug When I try to format the code, the output is always HTML escaped, although I set the escape flag to false

To Reproduce Steps to reproduce the behavior:

require 'rouge'
text = "  sleep 5; rm -rf /meowww\n  cat /dev/andom > /dev/zzda\n"
lexer = Rouge::Lexer.find_fancy('bash')
Rouge::Formatters::HTML.disable_escape!
Rouge::Formatters::HTML.escape_enabled?
formatter = Rouge::Formatters::HTML.new
highlighted = formatter.format(lexer.lex(text))

=> "  <span class=\"nb\">sleep </span>5<span class=\"p\">;</span> <span class=\"nb\">rm</span> <span class=\"nt\">-rf</span> /meowww\n  <span class=\"nb\">cat</span> /dev/urandom &amp;gt<span class=\"p\">;</span> /dev/sda\n"

Expected behavior Since escape_enabled? is false I expected &gt; stay the same, but it is changed to &amp;gt

System (please complete the following information):

  • OS: Debian 13
  • Ruby version: ruby 3.4.7
  • Rouge version: 4.6.1, also current branch 3332a9cdf1641410faa8eac884210cdee284d91d

istana avatar Dec 06 '25 23:12 istana