typst 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 43d8c84a75186f58f150a1b401f023269a87b65ff4181622d12ee0605e44e12c
4
+ data.tar.gz: b04f05668004a681b3dbf23cd8c5741e7a5d88418b1b282144b8a855575e9ae1
5
+ SHA512:
6
+ metadata.gz: 90852c841c355b42fd6f305627d6ce61e3ad2321e56e8a45bab1eff715888f232f76779eb217375e0da4855c24fd139cb14a86dea2a4aa53aeacccc816ece7da
7
+ data.tar.gz: 2e661ba34cdef35d3e9911b461cbd06815c31a2ac4408fa6be4a3395519f8a159bf3a3e31ae6cc573f78dbbe14a8818f0089dacf59f6ad6d779e80c79d02733d
data/Cargo.toml ADDED
@@ -0,0 +1,3 @@
1
+ [workspace]
2
+ members = ["ext/typst"]
3
+ resolver = "2"
data/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # typst-rb
2
+
3
+ Ruby binding to [typst](https://github.com/typst/typst),
4
+ a new markup-based typesetting system that is powerful and easy to learn.
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ gem install typst
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ ```ruby
15
+ require "typst"
16
+
17
+ # Compile `readme.typ` to PDF and save as `readme.pdf`
18
+ Typst::Pdf.new("readme.typ").write("readme.pdf")
19
+
20
+ # Or return PDF content as an array of bytes
21
+ pdf_bytes = Typst::Pdf.new("readme.typ").bytes
22
+ # => [37, 80, 68, 70, 45, 49, 46, 55, 10, 37, 128 ...]
23
+
24
+ # Or return PDF content as a string of bytes
25
+ document = Typst::Pdf.new("readme.typ").document
26
+ # => "%PDF-1.7\n%\x80\x80\x80\x80\n\n4 0 obj\n<<\n /Type /Font\n /Subtype ..."
27
+
28
+ # Compile `readme.typ` to SVG and save as `readme.svg`
29
+ Typst::Svg.new("readme.typ").write("readme.svg")
30
+
31
+ # Or return SVG content as an array of pages
32
+ pages = Typst::Svg.new("readme.typ").pages
33
+ # => ["<svg class=\"typst-doc\" viewBox=\"0 0 595.2764999999999 841.89105\" ..."
34
+
35
+ # Compile `readme.typ` to SVG and save as `readme.html`
36
+ Typst::Html.new("readme.typ", "README").write("readme.html")
37
+
38
+ # Or return HTML content
39
+ markup = Typst::Html.new("readme.typ", "README").markup
40
+ # => "\n<!DOCTYPE html>\n<html>\n<head>\n<title>README</title>\n</head>\n<bo..."
41
+
42
+ # Compile from a string to PDF
43
+ t = Typst::Pdf.from_s(%{hello world})
44
+
45
+ # Compile from a string to SVG
46
+ t = Typst::Svg.from_s(%{hello world})
47
+
48
+ # Compile from a string to PDF
49
+ t = Typst::Html.from_s(%{hello world})
50
+
51
+ # A more complex example of compiling from string
52
+ main = %{
53
+ #import "template.typ": *
54
+
55
+ #show: template.with()
56
+
57
+ #lorem(50)
58
+
59
+ #image("icon.svg")
60
+ }
61
+
62
+ template = %{
63
+ #let template(body) = {
64
+ set text(12pt, font: "Example")
65
+ body
66
+ }
67
+ }
68
+
69
+ icon = File.read("icon.svg")
70
+ font_bytes = File.read("Example.ttf")
71
+
72
+ t = Typst::Pdf.from_s(main, dependencies: { "template.typ" => template, "icon.svg" => icon }, fonts: { "Example.ttf" => font_bytes })
73
+ ```
74
+
75
+ ## Contributors & Acknowledgements
76
+ typst-rb is based on [typst-py](https://github.com/messense/typst-py) by [messense](https://github.com/messense)
77
+
78
+ ## License
79
+
80
+ This work is released under the Apache-2.0 license. A copy of the license is provided in the [LICENSE](./LICENSE) file.
data/README.typ ADDED
@@ -0,0 +1,83 @@
1
+
2
+ #show link: underline
3
+ #show link: set text(blue)
4
+
5
+ = typst-rb
6
+
7
+ Ruby binding to #link("https://github.com/typst/typst")[typst], a new markup-based typesetting system that is powerful and easy to learn.
8
+
9
+ == Installation
10
+
11
+ ```bash
12
+ gem install typst
13
+ ```
14
+
15
+ == Usage
16
+
17
+ ```ruby
18
+ require "typst"
19
+
20
+ # Compile `readme.typ` to PDF and save as `readme.pdf`
21
+ Typst::Pdf.new("readme.typ").write("readme.pdf")
22
+
23
+ # Or return PDF content as an array of bytes
24
+ pdf_bytes = Typst::Pdf.new("readme.typ").bytes
25
+ # => [37, 80, 68, 70, 45, 49, 46, 55, 10, 37, 128 ...]
26
+
27
+ # Or return PDF content as a string of bytes
28
+ document = Typst::Pdf.new("readme.typ").document
29
+ # => "%PDF-1.7\n%\x80\x80\x80\x80\n\n4 0 obj\n<<\n /Type /Font\n /Subtype ..."
30
+
31
+ # Compile `readme.typ` to SVG and save as `readme.svg`
32
+ Typst::Svg.new("readme.typ").write("readme.svg")
33
+
34
+ # Or return SVG content as an array of pages
35
+ pages = Typst::Svg.new("readme.typ").pages
36
+ # => ["<svg class=\"typst-doc\" viewBox=\"0 0 595.2764999999999 841.89105\" ..."
37
+
38
+ # Compile `readme.typ` to SVG and save as `readme.html`
39
+ Typst::Html.new("readme.typ", "README").write("readme.html")
40
+
41
+ # Or return HTML content
42
+ markup = Typst::Html.new("readme.typ", "README").markup
43
+ # => "\n<!DOCTYPE html>\n<html>\n<head>\n<title>README</title>\n</head>\n<bo..."
44
+
45
+ # Compile from a string to PDF
46
+ t = Typst::Pdf.from_s(%{hello world})
47
+
48
+ # Compile from a string to SVG
49
+ t = Typst::Svg.from_s(%{hello world})
50
+
51
+ # Compile from a string to PDF
52
+ t = Typst::Html.from_s(%{hello world})
53
+
54
+ # A more complex example of compiling from string
55
+ main = %{
56
+ #import "template.typ": *
57
+
58
+ #show: template.with()
59
+
60
+ #lorem(50)
61
+
62
+ #image("icon.svg")
63
+ }
64
+
65
+ template = %{
66
+ #let template(body) = {
67
+ set text(12pt, font: "Example")
68
+ body
69
+ }
70
+ }
71
+
72
+ icon = File.read("icon.svg")
73
+ font_bytes = File.read("Example.ttf")
74
+
75
+ t = Typst::Pdf.from_s(main, dependencies: { "template.typ" => template, "icon.svg" => icon }, fonts: { "Example.ttf" => font_bytes })
76
+ ```
77
+
78
+ == Contributors & Acknowledgements
79
+ typst-rb is based on #link("https://github.com/messense/typst-py")[typst-py] by #link("https://github.com/messense")[messense]
80
+
81
+ == License
82
+
83
+ This work is released under the Apache-2.0 license. A copy of the license is provided in the #link("https://github.com/actsasflinn/typst-rb/blob/main/LICENSE")[LICENSE] file.
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/extensiontask"
3
+ require "rubygems/package_task"
4
+ require "bundler"
5
+
6
+ CROSS_PLATFORMS = %w[
7
+ aarch64-linux
8
+ arm64-darwin
9
+ x64-mingw32
10
+ x86_64-darwin
11
+ x86_64-linux
12
+ x86_64-linux-musl
13
+ ]
14
+
15
+ spec = Bundler.load_gemspec("typst.gemspec")
16
+
17
+ Gem::PackageTask.new(spec).define
18
+
19
+ Rake::ExtensionTask.new("typst", spec) do |ext|
20
+ ext.lib_dir = "lib/typst"
21
+ ext.source_pattern = "*.{rs,toml}"
22
+ ext.cross_compile = true
23
+ ext.cross_platform = CROSS_PLATFORMS
24
+ end