class

Hwaro::Content::Processors::RenderHooks::HookRenderContext

Inherits Reference / Object

Renders one hook template against a small page/config variable set plus per-element vars (destination/text/alt/level/...). Mirrors ShortcodeProcessor#render_shortcode_jinja: compiled templates are cached by source.hash ^ salt (a hook-specific salt keeps entries from colliding with the page-template/shortcode caches that can share the same underlying Hash), worker-local when @cache_mutex is nil, mutex-guarded otherwise. A Crinja::TemplateError during compile or render warns once per hook per build and falls back to hand-written markup matching Markd's stock output shape.

Constants

SALT_BLOCKQUOTE = 4777280455127813963_u64
SALT_CODEBLOCK = 4850170388057902923_u64
SALT_HEADING = 5207640305650585419_u64
SALT_IMAGE = 5281949712387100491_u64
SALT_LINK = 5497010905425071947_u64

Distinct per-hook salts — arbitrary, just pairwise distinct and unlikely to collide with the shortcode cache's own salt.

SALT_TABLE = 6071206668070244171_u64

Constructors

new(registry : Registry, env : Crinja, template_cache : Hash(UInt64, Crinja::Template), cache_mutex : Mutex | Nil, page_vars : Hash(String, Crinja::Value), mermaid_bypass : Bool, admonition_bypass : Bool = false)
Source

Instance methods

admonition_bypass?

Same idea for > [!NOTE]-style blockquotes: with [markdown] admonitions = true they keep rendering the stock shape so postprocess_admonitions can rewrite them, instead of going through the blockquote hook.

Source
blockquote?
Source
codeblock?
Source
heading?
Source
image?
Source
mermaid_bypass?

Config-decided bypass: a mermaid fence renders through the existing mermaid pipeline (postprocess_mermaid) instead of the codeblock hook when [markdown] mermaid = true.

Source
registry_fingerprint

Exposed so cache-key builders (e.g. render_body_cached) can fold hook-template changes into their memo key without holding a Registry reference of their own.

Source
render_blockquote(text : String) : String

text is the captured, already-rendered inner HTML of the blockquote (block-level: paragraphs, lists, nested quotes...).

Source
render_codeblock(lang : String, options : String, code : String, highlighted : String, name : String = "", copy : String = "") : String

lang/options/code arrive already escaped; highlighted is the pre-highlighted (server mode) body HTML, or "" when highlighting didn't apply — templates choose between {{ highlighted }} and {{ code }}. name is the parsed {name=...}/{title=...} label ("" when absent) so templates don't have to re-parse options. copy is "true" when the copy button applies to this block ("" otherwise) — templates decide what markup, if any, to emit for it.

Source
render_heading(level : Int32, text : String, id : String) : String

id is the already-deduped heading id (custom {#id} or a generated slug — see HeadingIds.assign); text is the captured inner HTML with any <!--HID:...--> marker removed.

Source
render_image(destination : String, alt : String, title : String) : String

alt is the captured plain text of the image's children (Markd's @disable_tag protocol still applies — see HookedRenderer#image).

Source
render_table(html : String, header_html : String, body_html : String) : String

html is the complete stock <table>...</table> markup; header_html/body_html are its <thead>/<tbody> sections (body_html is "" for a header-only table) so templates can rebuild the table without re-parsing html. Blank lines are collapsed out of the result: table hooks run in the pre-markd line stream (TableParser), where markd ends an HTML block at the first blank line — a blank line in the hook output would split the table markup into a truncated HTML block plus escaped-text leftovers.

Source
table?
Source