From fbfcb2eb22cc4a95e4b85bba025961b86dcfa2c2 Mon Sep 17 00:00:00 2001 From: Han-Miru Kim Date: Thu, 21 Nov 2024 23:54:54 +0100 Subject: [PATCH 1/3] fix inlineMathTemplate --- projects/rehype-typst/lib/index.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/projects/rehype-typst/lib/index.js b/projects/rehype-typst/lib/index.js index bae6358e..b81c8a4d 100644 --- a/projects/rehype-typst/lib/index.js +++ b/projects/rehype-typst/lib/index.js @@ -162,9 +162,10 @@ async function renderToSVGString_($typst, code, displayMode) { #let s = state("t", (:)) -#let pin(t) = locate(loc => { - style(styles => s.update(it => it.insert(t, measure(line(length: loc.position().y + 0.25em), styles).width) + it)) -}) +#let pin(t) = context { + let width = measure(line(length: here().position().y + 0.25em)).width + s.update(it => it.insert(t, width) + it) +} #show math.equation: it => { box(it, inset: (top: 0.5em, bottom: 0.5em)) @@ -172,9 +173,9 @@ async function renderToSVGString_($typst, code, displayMode) { $pin("l1")${code}$ -#locate(loc => [ - #metadata(s.final(loc).at("l1"))