Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/actsasflinn/typst-rb
Ruby binding to typst, a new markup-based typesetting system that is powerful and easy to learn.
https://github.com/actsasflinn/typst-rb
Last synced: 6 days ago
JSON representation
Ruby binding to typst, a new markup-based typesetting system that is powerful and easy to learn.
- Host: GitHub
- URL: https://github.com/actsasflinn/typst-rb
- Owner: actsasflinn
- License: apache-2.0
- Created: 2023-11-24T04:00:09.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-04-09T00:09:35.000Z (7 months ago)
- Last Synced: 2024-08-09T13:44:29.832Z (3 months ago)
- Language: Rust
- Homepage:
- Size: 4.92 MB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-typst - typst-rb - Ruby binding to typst (Integrations & Tools / Programming)
README
# typst-rb
Ruby binding to [typst](https://github.com/typst/typst),
a new markup-based typesetting system that is powerful and easy to learn.## Installation
```bash
gem install typst
```## Usage
```ruby
require "typst"# Compile `readme.typ` to PDF and save as `readme.pdf`
Typst::Pdf.new("readme.typ").write("readme.pdf")# Or return PDF content as an array of bytes
pdf_bytes = Typst::Pdf.new("readme.typ").bytes
# => [37, 80, 68, 70, 45, 49, 46, 55, 10, 37, 128 ...]# Or return PDF content as a string of bytes
document = Typst::Pdf.new("readme.typ").document
# => "%PDF-1.7\n%\x80\x80\x80\x80\n\n4 0 obj\n<<\n /Type /Font\n /Subtype ..."# Compile `readme.typ` to SVG and save as `readme.svg`
Typst::Svg.new("readme.typ").write("readme.svg")# Or return SVG content as an array of pages
pages = Typst::Svg.new("readme.typ").pages
# => [" "\n\n\n\nREADME\n\n template, "icon.svg" => icon }, fonts: { "Example.ttf" => font_bytes })# From a zip file that includes a main.typ
# zip file include flat dependencies included and a fonts directory
Typst::Pdf::from_zip("working_directory.zip")# From a zip with a named main typst file
Typst::Pdf::from_zip("working_directory.zip", "hello.typ")
```## Contributors & Acknowledgements
typst-rb is based on [typst-py](https://github.com/messense/typst-py) by [messense](https://github.com/messense)## License
This work is released under the Apache-2.0 license. A copy of the license is provided in the [LICENSE](./LICENSE) file.