SabrinaJewson / cmarker.typ

Transpile CommonMark Markdown to Typst, from within Typst!
MIT License
28 stars 1 forks source link

Image paths are treated relative to installation path #6

Closed yuppity closed 7 months ago

yuppity commented 7 months ago
$ cd $(mktemp -d)
$ curl -so img.png "https://placehold.co/600x400"
$ echo '#import "@preview/cmarker:0.1.0"' > test.typ
$ echo '#cmarker.render(read("test.md"))' >> test.typ
$ echo '![Some image](img.png)' > test.md
$ cat test.typ
#import "@preview/cmarker:0.1.0"
#cmarker.render(read("test.md"))
$ cat test.md
![Some image](img.png)
$ typst compile test.typ
error: file not found (searched at /home/user01/.cache/typst/packages/preview/cmarker/0.1.0/img.png)
   ┌─ @preview/cmarker:0.1.0/lib.typ:19:9
   │
19 │     eval(rendered, mode: "markup", scope: (
   │          ^^^^^^^^

help: error occurred in this call of function `image`
   ┌─ @preview/cmarker:0.1.0/lib.typ:21:25
   │
21 │       image: (..args) => image(..args),
   │                          ^^^^^^^^^^^^^

help: error occurred in this call of function `render`
  ┌─ test.typ:2:1
  │
2 │ #cmarker.render(read("test.md"))
  │  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This must be an oversight; would have expected the search to happen relative to the document path.

P.S. Extremely useful plugin. Thank you!

yuppity commented 7 months ago

Oh boy, just noticed #5. Closing.