module

Hwaro::Content::Processors::LineWrapper

Wraps already-highlighted (or plain-escaped) code body HTML with per-line <span class="line"> markup for line numbers / highlighted lines — pure string post-processing, zero Tartrazine calls, applied AFTER (and outside) ServerHighlighter's gated tokenization, over its already-cached result.

Constants

SPAN_CLOSE = "</span>"
SPAN_OPEN_PREFIX = "<span class=\""

Instance methods

drop_hidden(body : String, opts : FenceOptions::Options) : String

Removes hide_lines lines from an already highlighted (or escaped) body WITHOUT adding the per-line wrapper spans — the render-hook path hands templates plain highlighted/code strings, but the redaction promise (&quot;hidden lines are removed from the output&quot;) must hold before the text reaches any template. split_lines re-opens token spans across line boundaries, so dropping whole lines keeps the remaining markup balanced.

Source
split_lines(html : String) : Array(String)

Splits already-highlighted HTML (a flat stream of &lt;span class=&quot;...&quot;&gt;ESCAPED&lt;/span&gt; and bare ESCAPED text — never nested, and the escaped text never contains a raw &lt;/&gt;) into one string per physical source line, re-opening any span whose class carries across a newline (a token's value can itself contain \n, e.g. a multi-line string literal).

Source
wrap(body : String, linenos : Bool, start : Int32, opts : FenceOptions::Options) : String

Wraps each physical line of already-highlighted body in a &lt;span class=&quot;line&quot;&gt; ( hl appended for highlighted lines), optionally prefixing a &lt;span class=&quot;ln&quot;&gt; gutter number. hl_lines/hide_lines ranges are matched against the PHYSICAL 1-based line number — never shifted by linenostart.

Hidden lines are elided from the output but KEEP consuming their physical line numbers, so the gutter shows gaps (unlike Zola, which renumbers). This preserves the documented invariant that hl_lines and linenostart always target physical lines.

Source