Closed memset0 closed 3 months ago
Please give the expected output as well.
Please give the expected output as well.
The excepted output is two same lines, both as same as the second line in the wrong output.
Minimal case:
#let bb = $bold(b)$
$bb$
currently yields an empty equation.
Moving to typst-hs, as this can be reproduced without pandoc.
Tested with typst.app. Behavior is a bit surprising!
$bb$
$cc$
$bb(X)$
#let bb=$3$
$bb$
$bb(X)$
yields
I think that's expected: bb alone refers to the function (not text), typst shows the function name in monospace. If an argument is given the function is called. But after shadowing the function with the value 3, it's just 3 in both contexts.
Even more straightforward repro:
#let bb = 3
$bb$
should be '3' but is empty.
This works okay, so the problem seems specific to math mode:
#let emph = 3
#emph
OK, I have a hypothesis. See this code
https://github.com/jgm/typst-hs/blob/main/src/Typst/Evaluate.hs#L242-L260
When evaluating an equation we import the math module, and this clobbers the previous definition of bb
.
I'd like to understand better how this is supposed to work.
For example, overline
in math mode means math.overline; it doesn't mean what overline
means outside of math mode.
The way I interpret that is that the implicitly imported math
module takes precedence over prior bindings.
But apparently if you do #let bb = 3
outside the scope of the equation, this takes precedence over the implicitly imported math.bb
.
I'm probably understanding something wrong. The typst documentation doesn't really clarify this.
It's a bit under documented indeed... From what I understand you have summed it up already: in math mode the math functions shadow the standard functions, but both are shadowed by user-defined bindings defined in the current scope.
(By the way the standard functions will have their own std
module in the next major release)
Explain the problem.: When processing Typst source files, some specific variable names, such as bb, cannot be recognized in math mode (they are treated as blank). However, they work fine outside of math mode.
Pandoc version?: Pandoc 3.3, the online demo. From this link, you can also reproduce the bug.
An minimal example is as the following:
And the corresponding markdown (will also meet this bug when choose the other language) result: