class

Hwaro::Content::Processors::HighlightingRenderer

Inherits Markd::HTMLRenderer < Markd::Renderer < Reference < Object

Custom HTML renderer that adds syntax highlighting support Extends Markd's HTMLRenderer to customize code block output

Constants

CLOSE_TAG_RE = Regex.new("</(#{Markd::Rule::TAG_NAME_STRING})\\s*>")
RAW_HTML_RE = Regex.new(Markd::Rule::HTML_TAG_STRING, Regex::Options::IGNORE_CASE)
TRUSTED_COMMENT_RE = Regex.new("<!--HWARO-#{MarkdownExtensions::TRUSTED_MARK}.*?-->")
TRUSTED_OPEN_RE = Regex.new("<(#{Markd::Rule::TAG_NAME_STRING}) #{MarkdownExtensions::TRUSTED_MARK}#{Markd::Rule::ATTRIBUTE}*\\s*/?>")

Constructors

new(options : Markd::Options, highlight_enabled : Bool = true, server_mode : Bool = false)
Source

Instance methods

code_block(node : Markd::Node, entering : Bool)

Override code_block to add highlighting-specific attributes

Source
code_block_body(node : Markd::Node, lang : String | Nil)

In server mode, emit pre-highlighted spans instead of plain escaped text. Falls back to the default escaped output when the language has no lexer (the language-* class is still present for styling).

When fence options (line numbers / hl_lines) are present AND active, the body is wrapped per-line instead — but ONLY in server mode; client mode keeps this exact byte-for-byte legacy body no matter what options were parsed (see code_block, which is what adds the data-* attributes for the client-side case).

Source
html_block(node : Markd::Node, entering : Bool)

Safe mode replaces every raw-HTML node with an omission comment — including the <!--HWARO-SHORTCODE-PLACEHOLDER-N--> comments the shortcode pass leaves for its (trusted, template-rendered) output, which silently erased every shortcode. Keep exactly those placeholders; everything else in the node is still omitted.

Extension markup (tables, <del>, footnotes, math, …) is raw HTML to markd too: a node that STARTS with hwaro-marked markup (see MarkdownExtensions.trust) is kept, minus any author raw HTML in it.

Source
html_inline(node : Markd::Node, entering : Bool)
Source