typst-rb
Ruby binding to typst,
a new markup-based typesetting system that is powerful and easy to learn.
Installation
gem install typst
Usage
require "typst"
Typst::Pdf.new("readme.typ").write("readme.pdf")
pdf_bytes = Typst::Pdf.new("readme.typ").bytes
document = Typst::Pdf.new("readme.typ").document
Typst::Svg.new("readme.typ").write("readme.svg")
pages = Typst::Svg.new("readme.typ").pages
Typst::Png.new("readme.typ").write("readme.png")
pages = Typst::Png.new("readme.typ").pages
Typst::Html.new("readme.typ", title: "README").write("readme.html")
markup = Typst::Html.new("readme.typ", title: "README").document
Typst::HtmlExperimental.new("readme.typ").write("readme.html")
markup = Typst::HtmlExperimental.new("readme.typ").document
t = Typst::Pdf.from_s(%{hello world})
t = Typst::Svg.from_s(%{hello world})
t = Typst::Png.from_s(%{hello world})
t = Typst::Html.from_s(%{hello world})
t = Typst::HtmlExperimental.from_s(%{hello world})
main = %{
#import "template.typ": *
#show: template.with()
#lorem(50)
#image("icon.svg")
}
template = %{
#let template(body) = {
set text(12pt, font: "Example")
body
}
}
icon = File.read("icon.svg")
font_bytes = File.read("Example.ttf")
t = Typst::Pdf.from_s(main, dependencies: { "template.typ" => template, "icon.svg" => icon }, fonts: { "Example.ttf" => font_bytes })
Typst::Pdf::from_zip("working_directory.zip")
Typst::Pdf::from_zip("working_directory.zip", "hello.typ")
Typst::Query.new("heading", "readme.typ").result
Typst::Query.new("heading", "readme.typ", format: "json").result(raw: true)
Typst::Query.new("heading", "readme.typ", format: "yaml").result(raw: true)
Contributors & Acknowledgements
typst-rb is based on typst-py by messense
License
This work is released under the Apache-2.0 license. A copy of the license is provided in the LICENSE file.