No project description provided
Project description
typst-py
Python binding to typst, a new markup-based typesetting system that is powerful and easy to learn.
Installation
pip install typst
Usage
import typst
# Compile `hello.typ` to PDF and save as `hello.pdf`
typst.compile("hello.typ", output="hello.pdf")
# Compile `hello.typ` to PNG and save as `hello.png`
typst.compile("hello.typ", output="hello.png", format="png", ppi=144.0)
# Or pass `hello.typ` content as bytes
with open("hello.typ", "rb") as f:
typst.compile(f.read(), output="hello.pdf")
# Or return PDF content as bytes
pdf_bytes = typst.compile("hello.typ")
# Also for svg
svg_bytes = typst.compile("hello.typ", format="svg")
# For multi-page export (the template is the same as the typst cli)
images = typst.compile("hello.typ", output="hello{n}.png", format="png")
# Or use Compiler class to avoid reinitialization
compiler = typst.Compiler("hello.typ")
compiler.compile(format="png", ppi=144.0)
# Query something
import json
values = json.loads(typst.query("hello.typ", "<note>", field="value", one=True))
Passing values
You can pass values to the compiled Typst file with the sys_inputs argument. For example:
import json
import typst
persons = [{"name": "John", "age": 35}, {"name": "Xoliswa", "age": 45}]
sys_inputs = {"persons": json.dumps(persons)}
typst.compile(input="main.typ", output="ages.pdf", sys_inputs=sys_inputs)
The following example shows how the passed data can be used in a Typst file.
#let persons = json(bytes(sys.inputs.persons))
#for person in persons [
#person.name is #person.age years old. \
]
License
This work is released under the Apache-2.0 license. A copy of the license is provided in the LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file typst-0.14.1.tar.gz.
File metadata
- Download URL: typst-0.14.1.tar.gz
- Upload date:
- Size: 56.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8424387c4ea709caf0dcd54c44f736f86cdde421ac86f9a5d2fa76ba4978b50e
|
|
| MD5 |
33db1654cdd223234d21f47bb4b8606b
|
|
| BLAKE2b-256 |
94f83afaafaf4bb111cfbf330df584bb27355dfb8a16f1a4d65169d22650b2ff
|
File details
Details for the file typst-0.14.1-cp313-cp313t-win_amd64.whl.
File metadata
- Download URL: typst-0.14.1-cp313-cp313t-win_amd64.whl
- Upload date:
- Size: 21.0 MB
- Tags: CPython 3.13t, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6acfb92cb1cd55ca7ace1e3cb4244de7d6aea43def0f4fb0a86bc4acc546cb0
|
|
| MD5 |
c9bdf97f3a16998676cccf2c3a24f91e
|
|
| BLAKE2b-256 |
45fd9664b1f329e88c11e78f4931cd019bf56e6b39c5730c1a61f98578ab3c55
|
File details
Details for the file typst-0.14.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: typst-0.14.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 25.6 MB
- Tags: CPython 3.13t, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9824868688a011b645275f3252a217e18344f043683fa2a34a0c9e862e7cecd5
|
|
| MD5 |
b0f3568ad6faa7a20330721c9d8b16db
|
|
| BLAKE2b-256 |
24bca68b45d34fbd387846fe00b0cb8ffa8689a894e9058e5d01e7a6001a36dc
|
File details
Details for the file typst-0.14.1-cp313-cp313t-manylinux_2_17_s390x.manylinux2014_s390x.whl.
File metadata
- Download URL: typst-0.14.1-cp313-cp313t-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 26.7 MB
- Tags: CPython 3.13t, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2178364f3787cefd2bfc2473cb2f37b7142b2ef6db7a8909344a03de506577a5
|
|
| MD5 |
d2dccd009db7435b14f3ddbe38d9f4da
|
|
| BLAKE2b-256 |
da843c1f14e25e897178741aa4888f77a654a48dd36db9527e25db50930d2edb
|
File details
Details for the file typst-0.14.1-cp313-cp313t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.
File metadata
- Download URL: typst-0.14.1-cp313-cp313t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 28.0 MB
- Tags: CPython 3.13t, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e86d766f13590b67fb36764ff0e5e89710a7e2fea8ecdc41fc9bf38aa6de1c9
|
|
| MD5 |
f51e79786bfbf07ef5b4527accbbed1a
|
|
| BLAKE2b-256 |
aad29bad4308695486857df6c59d11b0e04c6d45e9bf9f02c20c47d82dc55140
|
File details
Details for the file typst-0.14.1-cp313-cp313t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: typst-0.14.1-cp313-cp313t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 26.3 MB
- Tags: CPython 3.13t, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af9dd117af2f0c808cb1937acb9c88dda4895d9f5670fdff8c8a67281775c49c
|
|
| MD5 |
9390ddffdd56bfd55a6de182204dca37
|
|
| BLAKE2b-256 |
d82e9948598f65fbff2b13e8e98db0a776f1f04fd873d544a9961790cb5fa367
|
File details
Details for the file typst-0.14.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: typst-0.14.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 26.3 MB
- Tags: CPython 3.13t, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f695316ff4aab056d49dec04c4f34a6a29a26694ef8fdc85b1eafe8c7b589ec4
|
|
| MD5 |
463004c39f9e9853e31a408276a985f3
|
|
| BLAKE2b-256 |
3bbd1b63d8615272c9e3424ebe9c89bf9a7ff938a500c5a2ea63d7128f69399c
|
File details
Details for the file typst-0.14.1-cp313-cp313t-macosx_11_0_arm64.whl.
File metadata
- Download URL: typst-0.14.1-cp313-cp313t-macosx_11_0_arm64.whl
- Upload date:
- Size: 22.2 MB
- Tags: CPython 3.13t, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b14efb183e71aac2f15d83a11c4d90d474c07ed4bb021a574cdfcffe5fdb3146
|
|
| MD5 |
cac76d38ca2fe2214dfe427fd85e5f14
|
|
| BLAKE2b-256 |
c7162d1763c1c5a00467b66d1ef8f1e9c433e58722799476b0a88a52438d38b2
|
File details
Details for the file typst-0.14.1-cp313-cp313t-macosx_10_12_x86_64.whl.
File metadata
- Download URL: typst-0.14.1-cp313-cp313t-macosx_10_12_x86_64.whl
- Upload date:
- Size: 22.6 MB
- Tags: CPython 3.13t, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
259e31fac599b21187384942a806778be35d2391362e7f3bf3970b74a1581008
|
|
| MD5 |
270a9cec994ed2b930053d8d678c993e
|
|
| BLAKE2b-256 |
76dc5f3b7f74934c95ffca6d1747bad6fc6b80d57d5170a3b6be726b70b1b135
|
File details
Details for the file typst-0.14.1-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: typst-0.14.1-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 21.0 MB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a327226c639510d163578f454062f80505332a91f7599eb8f72d51f172a0f19
|
|
| MD5 |
4c437ac26760e52c6248b0d1052d988a
|
|
| BLAKE2b-256 |
db20921d8b769d65c9ebacf0ecea5aee1cde0c271ea526e7b16f8a3c25c7c2fd
|
File details
Details for the file typst-0.14.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: typst-0.14.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 25.6 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ca7303acec9fcbf06d949d8c7c1d5ccb986c1ac96a8fbdf08e25ac338df4a92
|
|
| MD5 |
7bd6e74d9f8d9f03a4af9511917e50b5
|
|
| BLAKE2b-256 |
d95b46e82ef31545df4b7ba1e371b4e81cb51ebb5f4f7b727814480ddd4250c1
|
File details
Details for the file typst-0.14.1-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.
File metadata
- Download URL: typst-0.14.1-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 26.7 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6488e56b6991a7fa72dc76326420e48af88b8d5524f467c7ec9ac50058d0ae95
|
|
| MD5 |
bec0b330a0e5f220a3b1bcd59c174671
|
|
| BLAKE2b-256 |
1fca997743f5990f0921ddfbe9db16539ea4629396bf08e7f866f3b9aa9ddc99
|
File details
Details for the file typst-0.14.1-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.
File metadata
- Download URL: typst-0.14.1-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 28.0 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b001ce9193650e3d4d743c1f098f5ad51ab3aa8fc22d7cf2a1078e3092d554a2
|
|
| MD5 |
b043de82894b7cda8020262fc3c5ede9
|
|
| BLAKE2b-256 |
0cc09ef857ba619fcc4436fe74523386123040a194fb370e371fcf0084289c0d
|
File details
Details for the file typst-0.14.1-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: typst-0.14.1-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 26.3 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77a16fd700fd1e9108b8e5b25529e09f42e9a9d73163bba14010ae7864d43c42
|
|
| MD5 |
34b92e761b969b4c869f67d5e97d085e
|
|
| BLAKE2b-256 |
2f30315399bd09082d123d7e502be917b908f4a3e105406e59dcaf8b0431b1c4
|
File details
Details for the file typst-0.14.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: typst-0.14.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 26.4 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8a249d78debf8446faa72d928762fbfab3ca934b549b6122405533bffc3666c
|
|
| MD5 |
60f112f390c15d045c14400a7b04671d
|
|
| BLAKE2b-256 |
bb5fb0046efddb21ae07d02b8f22cd29202f628ff2a9e25176e71a9532324c2c
|
File details
Details for the file typst-0.14.1-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: typst-0.14.1-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 22.2 MB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
386fdd45862d69f53960576a9a8834079bef1c0cea7bcd6e31af8f7f9b3f1a2c
|
|
| MD5 |
eedc71fa3dab317bbd2d70d04df4e9d2
|
|
| BLAKE2b-256 |
0547740e63391763ad54eb8b299dc2a3085bf57a4f7eccd42e1199d32b866f27
|
File details
Details for the file typst-0.14.1-cp38-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: typst-0.14.1-cp38-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 22.6 MB
- Tags: CPython 3.8+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4498657165994502aaba75364c5830c44509bd06d28b1b1da2d0de29c5271a65
|
|
| MD5 |
c1ac3302739ab104b60ab6772a960c22
|
|
| BLAKE2b-256 |
9a061bb959ad6ad8117c5c23fb19584b32b3924cfdee3bad56448367af25567f
|