This is likely because html.frame
isn’t an inline element (only text decoration elements and horizontal spacing are inline), so it interrupts paragraphs, similarly to e.g. image
outside of html export. You’ll need to wrap them in a box
for inline equations:
#show math.equation: html.frame
#show math.equation.where(block: false): box
That’s because you’re wrapping the canvas in a frame, causing the canvas to be exported as SVG, and then the show rule wrapping equations in html.frame
is being applied, which has no effect in SVG export (only in HTML export).
You’ll need to ensure the show rule is not applied inside a CeTZ canvas. One way to do this involves state
:
#let in-canvas = state("in-cetz-canvas", false)
#show math.equation: it => context {
if in-canvas.get() { it } else { html.frame(it) }
}
#show math.equation.where(block: false): box
#let canvas(..args) = {
in-canvas.update(true)
html.frame(cetz.canvas(..args))
in-canvas.update(false)
// NOTE: this simplified version assumes you won't
// create a canvas inside a canvas.
}