rouge-ruby/rouge · error · ArgumentError
Expected an instance of Rouge::Formatters::HTML, got #{forma
Error message
Expected an instance of Rouge::Formatters::HTML, got #{formatter.class}. Try HTML, HTMLDebug, or HTMLInline. What it means
Error "Expected an instance of Rouge::Formatters::HTML, got #{formatter.class}. Try HTML, HTMLDebug, or HTMLInline." thrown in rouge-ruby/rouge.
Source
Thrown at lib/rouge/formatters/html.rb:20
# frozen_string_literal: true
module Rouge
module Formatters
# Transforms a token stream into HTML output.
class HTML < Formatter
TABLE_FOR_ESCAPE_HTML = {
'&' => '&',
'<' => '<',
'>' => '>',
"\r" => "",
}.freeze
ESCAPE_REGEX = /[&<>\r]/.freeze
def self.assert_html_formatter!(formatter)
return formatter if formatter.respond_to?(:span)
raise ArgumentError.new("Expected an instance of Rouge::Formatters::HTML, got #{formatter.class}. Try HTML, HTMLDebug, or HTMLInline.")
end
tag 'html'
# @yield the html output.
def stream(tokens, &b)
tokens.each { |tok, val| yield span(tok, val) }
end
def span(tok, val)
return val if escape?(tok)
safe_span(tok, escape_special_html_chars(val))
end
def safe_span(tok, safe_val)
if tok == Token::Tokens::Text
safe_valView on GitHub (pinned to bd7dad7b09)
When it happens
Trigger: Thrown at lib/rouge/formatters/html.rb:20 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of rouge-ruby/rouge@bd7dad7b09 (2026-08-23).
Data as JSON: /api/errors/141d6cd136aa55d9.
Report an issue: GitHub.