jupyter-book / mystmd

Command line tools for working with MyST Markdown.
https://mystmd.org/guide
MIT License
219 stars 65 forks source link

Typst doesn't embed an external xref #1552

Closed choldgraf closed 2 months ago

choldgraf commented 2 months ago

There's a weird bug in the 2i2c report where building a PDF with Typst doesn't work because an external reference "doesn't exist in the document". The xref is pulled in just fine with myst start so I wonder if something is going on where Typst is expecting the reference to exist locally instead of in a remote doc.

Here's a link to the MyST markdown:

https://github.com/2i2c-org/report-czi-2021/blob/main/main.md?plain=1#L46

Here's the error that happens with myst build --typst:

error: label `<cool-myst-features>` does not exist in the document
   ┌─ _build/temp/myst7soLaE/report-main.typ:43:4
   │
43 │ Try @cool-myst-features.
   │     ^
^^^^^^^^^^^^^^^^^^

Link to the error in github actions logs: https://github.com/2i2c-org/report-czi-2021/actions/runs/11019631270/job/30602623239#step:7:29

I've tried the same thing with using xref for a labeled figure and the same issue happens.

rowanc1 commented 2 months ago

Yes, this is also the case if you reference something in another page in the project that isn't built in the PDF. (Also in latex)

It is a bit more tricky in that case, but these external references should just be turned into links!

choldgraf commented 2 months ago

Hmmm, do you have a recommended workaround for now other than to just not use an external reference for PDF builds? The problem is that it stops the PDF from building at all (I thought that since the --strict option exists, it would have kept going without that flag)

rowanc1 commented 2 months ago

I don't know a work around for typst at the moment. Let me see if there is an easy work around for this case though.

choldgraf commented 2 months ago

It's no hurry, I can just remove that xref - it was just there to show off some myst functionality as a preview.

rowanc1 commented 2 months ago

A fix is up, have tested it on your content. Which now builds without issue:

image