class

Hwaro::Models::HighlightConfig

Inherits Reference / Object

Syntax highlighting configuration

Constants

COPY_SNIPPET = "<style>.code-wrapper,.code-block{position:relative}.code-copy-btn{position:absolute;top:.4rem;right:.4rem;padding:.25rem .6rem;font:inherit;font-size:.75rem;color:inherit;background:transparent;border:1px solid currentColor;border-radius:.25rem;opacity:0;cursor:pointer;transition:opacity .15s}.code-wrapper:hover .code-copy-btn,.code-block:hover .code-copy-btn,.code-copy-btn:focus-visible,.code-copy-btn.copied{opacity:.75}</style>\n<script>document.addEventListener(\"DOMContentLoaded\",function(){document.querySelectorAll(\"pre[data-copy]\").forEach(function(pre){var w=pre.parentNode;var l=w.classList;if(!l||!(l.contains(\"code-wrapper\")||l.contains(\"code-block\"))){w=document.createElement(\"div\");w.className=\"code-wrapper\";pre.parentNode.insertBefore(w,pre);w.appendChild(pre);}var b=document.createElement(\"button\");b.type=\"button\";b.className=\"code-copy-btn\";b.textContent=\"Copy\";b.setAttribute(\"aria-label\",\"Copy code\");b.addEventListener(\"click\",function(){var c=pre.querySelector(\"code\");var t;if(c){var k=c.cloneNode(true);k.querySelectorAll(\"span.ln\").forEach(function(n){n.remove();});t=k.textContent;}else{t=pre.textContent;}navigator.clipboard.writeText(t).then(function(){b.classList.add(\"copied\");b.textContent=\"Copied!\";setTimeout(function(){b.classList.remove(\"copied\");b.textContent=\"Copy\";},2000);});});w.appendChild(b);});});</script>"

Copy-to-clipboard runtime for pre[data-copy] blocks: one DOM pass on DOMContentLoaded, appends a button, and copies the code's text on click. An existing .code-block (named fences) or .code-wrapper parent is reused as the positioning anchor — inserting a new wrapper inside .code-block would break its .code-block &gt; pre styling — otherwise the

 is wrapped in a fresh .code-wrapper. Copied
text strips the baked-in .ln line-number gutter spans (server-mode
linenos) so pasted code has no number prefixes. Theme-neutral —
currentColor only, revealed on hover/focus — and small enough to
inline, so no extra request in either highlight mode.

Constructors

Instance methods

copy

Adds a copy-to-clipboard button to fenced code blocks (per-block {copy=false}/{copy=true} overrides). Off by default so existing output is byte-identical.

Source
copy=(copy : Bool)

Adds a copy-to-clipboard button to fenced code blocks (per-block {copy=false}/{copy=true} overrides). Off by default so existing output is byte-identical.

Source
css_tag(cache_bust : String = "") : String

Generate the CSS link tag for highlighting

Source
enabled
Source
enabled=(enabled : Bool)
Source
js_tag(cache_bust : String = "") : String

Generate the JS script tag for highlighting. Server-side highlighting needs no JavaScript at all — unless the copy button is on, whose (dependency-free) runtime ships either way.

Source
line_numbers

Global default for fence-level linenos (see FenceOptions): when true, every fenced code block with a language gets line numbers unless it opts out with a per-block {linenos=false}. Off by default so existing output is unaffected.

Source
line_numbers=(line_numbers : Bool)

Global default for fence-level linenos (see FenceOptions): when true, every fenced code block with a language gets line numbers unless it opts out with a per-block {linenos=false}. Off by default so existing output is unaffected.

Source
mode

&quot;server&quot; (default) highlights at build time (Tartrazine lexers, hljs-compatible CSS classes) so no JavaScript ships; &quot;client&quot; injects Highlight.js and highlights in the browser — theme CSS keeps working either way.

Source
mode=(mode : String)

&quot;server&quot; (default) highlights at build time (Tartrazine lexers, hljs-compatible CSS classes) so no JavaScript ships; &quot;client&quot; injects Highlight.js and highlights in the browser — theme CSS keeps working either way.

Source
server?

True when code is highlighted at build time (no client-side JS).

Source
tags(cache_bust : String = "") : String

Generate both CSS and JS tags

Source
theme
Source
theme=(theme : String)
Source
use_cdn
Source
use_cdn=(use_cdn : Bool)
Source