jgm / typst-hs

Haskell library for parsing and evaluating typst
Other
44 stars 5 forks source link

`Encountered binding out of proper context` when using math variables #34

Closed Doublonmousse closed 9 months ago

Doublonmousse commented 9 months ago

Converting

#let a = $1$
#let b = $2$

$#a #b$

works but

#let a = $1$
#let b = $2$

$#a = #b$

results in an error

"binding_ooc/var3_not_working.typ" (line 5, column 3):
Encountered binding out of proper context

Another much more contrived example to reproduce the issue can be found at https://github.com/Doublonmousse/pandoc-typst-reproducer/tree/main/binding_ooc

jgm commented 9 months ago

typst-hs is parsing the final equation as

    [ Code
        "stdin"
        ( line 4 , column 3 )
        (Binding (BasicBind (Just (Identifier "a"))))
    , Text "="
    , Code "stdin" ( line 4 , column 8 ) (Ident (Identifier "b"))
    ]

rather than (as I'd expect)

    [ Code "stdin" ( line 4 , column 2 ) (Ident (Identifier "a"))
    , Text "="
    , Code "stdin" ( line 4 , column 8 ) (Ident (Identifier "b"))
    ]