Skip to content

Commit

Permalink
fix template
Browse files Browse the repository at this point in the history
  • Loading branch information
Enter-tainer committed Dec 10, 2024
1 parent cea3add commit 450a4f1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
26 changes: 14 additions & 12 deletions projects/rehype-typst/equation.typ
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@

#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)).width
s.update(it => it.insert(t, width) + it)
}

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

$pin("l1")1+e/sqrt(sqrt(a/c)/(e + c +a/b))$
$pin("l1")1+(e vec(a,b,c)) / sqrt(sqrt(a/c)/(e + c +a/b)/e)$ 123

#context [
#metadata(s.final().at("l1")) <label>
]

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

// #s.display()
// #locate(loc => {
// let s = s.final(loc)
// place(left+top, dx: 0pt, dy: s.l1, line(length: 100pt, stroke: red + 0.1pt))
// })
#context {
let s = s.final()
place(left + top, dx: 0pt, dy: s.l1, line(length: 100pt, stroke: red + 0.1pt))
}
4 changes: 2 additions & 2 deletions projects/rehype-typst/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default function rehypeTypst(options) {
const defaultEm = 11;
const height = parseFloat(root.children[0].properties['dataHeight']);
const width = parseFloat(root.children[0].properties['dataWidth']);
const shift = height - result.baselinePosition + 2.8; /* line up baselines */
const shift = height - result.baselinePosition;
const shiftEm = shift / defaultEm;
root.children[0].properties.style = `vertical-align: -${shiftEm}em;`;
root.children[0].properties.height = `${height / defaultEm}em`;
Expand Down Expand Up @@ -163,7 +163,7 @@ async function renderToSVGString_($typst, code, displayMode) {
#let s = state("t", (:))
#let pin(t) = context {
let width = measure(line(length: here().position().y + 0.25em)).width
let width = measure(line(length: here().position().y)).width
s.update(it => it.insert(t, width) + it)
}
Expand Down

0 comments on commit 450a4f1

Please sign in to comment.