Skip to content

zebra-init is called repeatedly for each code block #180

@ensko

Description

@ensko

When trying to override some zebraw settings, I noticed the following lines:

/// HTML code block supported by zebraw.
show: init-with-theme(default-theme)
set raw(tab-size: 114)
let in-mk-raw = state("shiroa:in-mk-raw", false)
let mk-raw(
it,
tag: "div",
inline: false,
) = {
theme-box(tag: tag, theme => {
show: init-with-theme(theme)

Line 235 does a regular zebraw-init (which init-with-theme is a wrapper for) as expected when using zebraw. However, mk-raw calls it again, and this is called in a show rule for every raw block:

show raw.where(block: false, tab-size: 114): it => context if shiroa-sys-target() == "paged" {
it
} else {
mk-raw(it, tag: "span", inline: true)
}
show raw.where(block: true, tab-size: 114): it => context if shiroa-sys-target() == "paged" {
rect(width: 100%, inset: (x: 4pt, y: 5pt), radius: 4pt, fill: code-extra-colors.bg, {
set text(fill: code-extra-colors.fg) if code-extra-colors.fg != none
set par(justify: false)
with-raw-theme(theme-style.code-theme, it)
})
} else {
mk-raw(it)
}

Ultimately, this means that zebraw settings can not be overridden.

Is there a particular reason for doing so? zebraw-init only sets some states, so there should be no benefit from calling it repeatedly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions