jackyzha0 / quartz

🌱 a fast, batteries-included static-site generator that transforms Markdown content into fully functional websites
https://quartz.jzhao.xyz
MIT License
7.35k stars 2.54k forks source link

bug(typst): inline-math crashes #1605

Open aarnphm opened 2 days ago

aarnphm commented 2 days ago

see https://github.com/jackyzha0/quartz/pull/1569

kimhanm commented 23 hours ago

I managed to track the bug to the upstream rehype-typst package. Its inline math template (found in node_modules/.../rehype-typst/lib/index.js)

#set page(height: auto, width: auto, margin: 0pt)

#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))
})

#show math.equation: it => {
  box(it, inset: (top: 0.5em, bottom: 0.5em))
}

$pin("l1")x$

#locate(loc => [
  #metadata(s.final(loc).at("l1")) <label>
])

generates an error upon compilation with typst directly, as it needs to be wrapped in "context expression" (see https://typst.app/docs/reference/context/). I haven't figured that out yet but I assume that is all that needs to be done.

kimhanm commented 18 hours ago

Created an upstream PR here: https://github.com/Myriad-Dreamin/typst.ts/pull/604 As far as I can tell, it doesn't require any changes to the quartz project apart from updating the dependency once it gets merged.

aarnphm commented 16 hours ago

Yeah we can let dependabot to do it so no worries. Thanks for leading the work.