typst 0.13.1 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/lib/typst.rb +25 -23
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26c5aa0d53ccc72726e84813f15e44c7af5058644e303e7a717c6e434f3491f9
|
4
|
+
data.tar.gz: e2a4c340aed40a83c85b2fbb369ecf6925b354d5bd01d794168933dfc3999a94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 064b3692ae5e033d33e6c2960ec53112a61abb76d1c69a66d07ea75f2ff284044fb85d9eefc9c7d510c3bc1f07f4447a2e2edf4983d864b696e36b418abdfab2
|
7
|
+
data.tar.gz: 38409e19ae6faaea38db473515a24df16d0e1bb2cd42fad113557e8e8ca13bfda4e9564976e68bf53ea4ae7624c9433d8a8679b30438a4bb39f7803b73677e5f
|
data/README.md
CHANGED
@@ -91,6 +91,16 @@ font_bytes = File.read("Example.ttf")
|
|
91
91
|
|
92
92
|
t = Typst::Pdf.from_s(main, dependencies: { "template.typ" => template, "icon.svg" => icon }, fonts: { "Example.ttf" => font_bytes })
|
93
93
|
|
94
|
+
# Pass values into a typst template using sys_inputs
|
95
|
+
sys_inputs_example = %{
|
96
|
+
#let persons = json(bytes(sys.inputs.persons))
|
97
|
+
|
98
|
+
#for person in persons [
|
99
|
+
#person.name is #person.age years old.\\
|
100
|
+
]
|
101
|
+
}
|
102
|
+
Typst::Pdf.from_s(sys_inputs_example, sys_inputs: { "persons" => [{"name": "John", "age": 35}, {"name": "Xoliswa", "age": 45}].to_json }).write("sys_inputs_example.pdf")
|
103
|
+
|
94
104
|
# From a zip file that includes a main.typ
|
95
105
|
# zip file include flat dependencies included and a fonts directory
|
96
106
|
Typst::Pdf::from_zip("working_directory.zip")
|
data/lib/typst.rb
CHANGED
@@ -9,18 +9,20 @@ module Typst
|
|
9
9
|
attr_accessor :input
|
10
10
|
attr_accessor :root
|
11
11
|
attr_accessor :font_paths
|
12
|
+
attr_accessor :sys_inputs
|
12
13
|
|
13
|
-
def initialize(input, root: ".", font_paths: [])
|
14
|
+
def initialize(input, root: ".", font_paths: [], sys_inputs: {})
|
14
15
|
self.input = input
|
15
16
|
self.root = Pathname.new(root).expand_path.to_s
|
16
17
|
self.font_paths = font_paths.collect{ |fp| Pathname.new(fp).expand_path.to_s }
|
18
|
+
self.sys_inputs = sys_inputs
|
17
19
|
end
|
18
20
|
|
19
21
|
def write(output)
|
20
22
|
File.open(output, "wb"){ |f| f.write(document) }
|
21
23
|
end
|
22
24
|
|
23
|
-
def self.from_s(main_source, dependencies: {}, fonts: {})
|
25
|
+
def self.from_s(main_source, dependencies: {}, fonts: {}, sys_inputs: {})
|
24
26
|
dependencies = {} if dependencies.nil?
|
25
27
|
fonts = {} if fonts.nil?
|
26
28
|
Dir.mktmpdir do |tmp_dir|
|
@@ -39,11 +41,11 @@ module Typst
|
|
39
41
|
File.write(tmp_font_file, font_bytes)
|
40
42
|
end
|
41
43
|
|
42
|
-
new(tmp_main_file, root: tmp_dir, font_paths: [relative_font_path])
|
44
|
+
new(tmp_main_file, root: tmp_dir, font_paths: [relative_font_path], sys_inputs: sys_inputs)
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
46
|
-
def self.from_zip(zip_file_path, main_file = nil)
|
48
|
+
def self.from_zip(zip_file_path, main_file = nil, sys_inputs: {})
|
47
49
|
dependencies = {}
|
48
50
|
fonts = {}
|
49
51
|
|
@@ -68,7 +70,7 @@ module Typst
|
|
68
70
|
fonts[Pathname.new(font_name).basename.to_s] = zipfile.file.read(font_name)
|
69
71
|
end
|
70
72
|
|
71
|
-
from_s(main_source, dependencies: dependencies, fonts: fonts)
|
73
|
+
from_s(main_source, dependencies: dependencies, fonts: fonts, sys_inputs: sys_inputs)
|
72
74
|
end
|
73
75
|
end
|
74
76
|
end
|
@@ -76,9 +78,9 @@ module Typst
|
|
76
78
|
class Pdf < Base
|
77
79
|
attr_accessor :bytes
|
78
80
|
|
79
|
-
def initialize(input, root: ".", font_paths: [])
|
80
|
-
super(input, root: root, font_paths: font_paths)
|
81
|
-
@bytes = Typst::_to_pdf(self.input, self.root, self.font_paths, File.dirname(__FILE__), false,
|
81
|
+
def initialize(input, root: ".", font_paths: [], sys_inputs: {})
|
82
|
+
super(input, root: root, font_paths: font_paths, sys_inputs: sys_inputs)
|
83
|
+
@bytes = Typst::_to_pdf(self.input, self.root, self.font_paths, File.dirname(__FILE__), false, sys_inputs)[0]
|
82
84
|
end
|
83
85
|
|
84
86
|
def document
|
@@ -89,9 +91,9 @@ module Typst
|
|
89
91
|
class Svg < Base
|
90
92
|
attr_accessor :pages
|
91
93
|
|
92
|
-
def initialize(input, root: ".", font_paths: [])
|
93
|
-
super(input, root: root, font_paths: font_paths)
|
94
|
-
@pages = Typst::_to_svg(self.input, self.root, self.font_paths, File.dirname(__FILE__), false,
|
94
|
+
def initialize(input, root: ".", font_paths: [], sys_inputs: {})
|
95
|
+
super(input, root: root, font_paths: font_paths, sys_inputs: sys_inputs)
|
96
|
+
@pages = Typst::_to_svg(self.input, self.root, self.font_paths, File.dirname(__FILE__), false, sys_inputs).collect{ |page| page.pack("C*").to_s }
|
95
97
|
end
|
96
98
|
|
97
99
|
def write(output)
|
@@ -115,9 +117,9 @@ module Typst
|
|
115
117
|
class Png < Base
|
116
118
|
attr_accessor :pages
|
117
119
|
|
118
|
-
def initialize(input, root: ".", font_paths: [])
|
119
|
-
super(input, root: root, font_paths: font_paths)
|
120
|
-
@pages = Typst::_to_png(self.input, self.root, self.font_paths, File.dirname(__FILE__), false,
|
120
|
+
def initialize(input, root: ".", font_paths: [], sys_inputs: {})
|
121
|
+
super(input, root: root, font_paths: font_paths, sys_inputs: sys_inputs)
|
122
|
+
@pages = Typst::_to_png(self.input, self.root, self.font_paths, File.dirname(__FILE__), false, sys_inputs).collect{ |page| page.pack("C*").to_s }
|
121
123
|
end
|
122
124
|
|
123
125
|
def write(output)
|
@@ -143,11 +145,11 @@ module Typst
|
|
143
145
|
attr_accessor :svg
|
144
146
|
attr_accessor :html
|
145
147
|
|
146
|
-
def initialize(input, title: nil, root: ".", font_paths: [])
|
147
|
-
super(input, root: root, font_paths: font_paths)
|
148
|
+
def initialize(input, title: nil, root: ".", font_paths: [], sys_inputs: {})
|
149
|
+
super(input, root: root, font_paths: font_paths, sys_inputs: sys_inputs)
|
148
150
|
title = title || File.basename(input, File.extname(input))
|
149
151
|
self.title = CGI::escapeHTML(title)
|
150
|
-
self.svg = Svg.new(self.input, root: self.root, font_paths: self.font_paths)
|
152
|
+
self.svg = Svg.new(self.input, root: self.root, font_paths: self.font_paths, sys_inputs: sys_inputs)
|
151
153
|
end
|
152
154
|
|
153
155
|
def markup
|
@@ -169,9 +171,9 @@ module Typst
|
|
169
171
|
class HtmlExperimental < Base
|
170
172
|
attr_accessor :bytes
|
171
173
|
|
172
|
-
def initialize(input, root: ".", font_paths: [])
|
173
|
-
super(input, root: root, font_paths: font_paths)
|
174
|
-
@bytes = Typst::_to_html(self.input, self.root, self.font_paths, File.dirname(__FILE__), false,
|
174
|
+
def initialize(input, root: ".", font_paths: [], sys_inputs: {})
|
175
|
+
super(input, root: root, font_paths: font_paths, sys_inputs: sys_inputs)
|
176
|
+
@bytes = Typst::_to_html(self.input, self.root, self.font_paths, File.dirname(__FILE__), false, sys_inputs)[0]
|
175
177
|
end
|
176
178
|
|
177
179
|
def document
|
@@ -184,10 +186,10 @@ module Typst
|
|
184
186
|
attr_accessor :format
|
185
187
|
attr_accessor :result
|
186
188
|
|
187
|
-
def initialize(selector, input, field: nil, one: false, format: "json", root: ".", font_paths: [])
|
188
|
-
super(input, root: root, font_paths: font_paths)
|
189
|
+
def initialize(selector, input, field: nil, one: false, format: "json", root: ".", font_paths: [], sys_inputs: {})
|
190
|
+
super(input, root: root, font_paths: font_paths, sys_inputs: sys_inputs)
|
189
191
|
self.format = format
|
190
|
-
self.result = Typst::_query(selector, field, one, format, self.input, self.root, self.font_paths, File.dirname(__FILE__), false,
|
192
|
+
self.result = Typst::_query(selector, field, one, format, self.input, self.root, self.font_paths, File.dirname(__FILE__), false, sys_inputs)
|
191
193
|
end
|
192
194
|
|
193
195
|
def result(raw: false)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typst
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flinn
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rb_sys
|
@@ -37,6 +37,20 @@ dependencies:
|
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '2.4'
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: hexapdf
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
type: :development
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
40
54
|
email: flinn@actsasflinn.com
|
41
55
|
executables: []
|
42
56
|
extensions:
|
@@ -90,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
104
|
- !ruby/object:Gem::Version
|
91
105
|
version: '0'
|
92
106
|
requirements: []
|
93
|
-
rubygems_version: 3.6.
|
107
|
+
rubygems_version: 3.6.8
|
94
108
|
specification_version: 4
|
95
109
|
summary: Ruby binding to typst, a new markup-based typesetting system that is powerful
|
96
110
|
and easy to learn.
|