messense/typst-py

Passing json data as argument parameter

rousbound opened this issue · 3 comments

I think it would be desirable to pass json data directly to typst. Without needing typst to read the json file from disk.

What json data? Can you elaborate?

I'm sorry for my unclear explanation.

I meant that it would be desirable for generating dynamic documents, to have an API such as the following:

import typst

compiler = typst.Compiler(".")
json_file = get_json_file()
pdf_bytes = typst.compile("hello.typ", json_file=json_file)

So in the document I could retrieve the json file in a way like:

#let data = json(json_file) 

Or something else in a similar way.

The advantage is to load json in memory, instead of writing the json in a directory and making typst reading it.

I don't know if that is possible without deeper modifications to typst though.

We found a plausible path to solve this feature in: typst/typst#1158 (comment)