| Crates.io | d2typ |
| lib.rs | d2typ |
| version | 0.1.3 |
| created_at | 2025-07-19 19:16:26.090319+00 |
| updated_at | 2025-07-19 20:17:05.228103+00 |
| description | A command-line tool for converting structured data to Typst format |
| homepage | https://github.com/acture/d2typ |
| repository | https://github.com/acture/d2typ |
| max_upload_size | |
| id | 1760448 |
| size | 61,339 |
A command-line tool for converting structured data to Typst format.
cargo install d2typ
# If formula is submitted to Homebrew
brew install d2typ
git clone https://github.com/yourusername/d2typ.git
cd d2typ
cargo install --path .
# Convert a CSV file to Typst format
d2typ input.csv > output.typ
# Convert a JSON file to Typst format
d2typ input.json > output.typ
# Specify output file
d2typ input.yaml -o output.typ
# Read from stdin
cat input.toml | d2typ > output.typ
Usage: d2typ [OPTIONS] [INPUT]
Arguments:
[INPUT] Input file (omit for stdin)
Options:
-o, --output <OUTPUT> Output file (omit for stdout)
-f, --format <FORMAT> Force input format [default: auto] [possible values: auto, csv, json, yaml, toml, xlsx]
--no-header For CSV input: treat as no header
--sheet <SHEET> For XLSX input: select sheet
-h, --help Print help
-V, --version Print version
Input (data.csv):
name,age,city
Alice,30,New York
Bob,25,San Francisco
Charlie,35,Seattle
Command:
d2typ data.csv > data.typ
Output (data.typ):
#let data = [
{ name: Alice, age: 30, city: New York },
{ name: Bob, age: 25, city: San Francisco },
{ name: Charlie, age: 35, city: Seattle }
]
Input (data.json):
{
"users": [
{"name": "Alice", "age": 30},
{"name": "Bob", "age": 25}
],
"version": 1.0
}
Command:
d2typ data.json > data.typ
Output (data.typ):
#let data = {
users: [
{ name: Alice, age: 30 },
{ name: Bob, age: 25 }
],
version: 1.0
}
Once you've converted your data to Typst format, you can use it in your Typst documents:
#import "data.typ"
// Access the data
#for user in data.users [
- #user.name is #user.age years old
]
cargo build
cargo run -- [arguments]
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0-only) - see the LICENSE file for details.