typst 0.14.2 → 0.14.2.1
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/Rakefile +3 -7
- data/ext/typst/Cargo.toml +2 -4
- data/ext/typst/src/lib.rs +39 -35
- data/lib/typst/typst.bundle +0 -0
- metadata +4 -5
- data/lib/typst/typst.so +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 77a2b80d3ddc7e3b8a2fd44c365b3a7c9464383894bb3a61e869d87085baa8a2
|
|
4
|
+
data.tar.gz: ce2e709afe2b9b76f73292ec13df74815ac0ff7dc7fc4636a58d73b7122ad391
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b0e845ea82c232ed88b4dd6c159b814aad54199ff85829a7edb18a42346abf887e138345efca9e1ab1a2ca8b379b161bda3448162cd128f811b342815a7f0b85
|
|
7
|
+
data.tar.gz: 73c99e328ea7aa5ba58d574b7b7770b86355f97787e2df6de4a4578913ae7d72082e11309309ae2ccd2f3882ceba26a482e60de8b25dc188a78e678ca41c99b7
|
data/Rakefile
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
require "bundler/gem_tasks"
|
|
2
|
-
require "
|
|
2
|
+
require "rb_sys/extensiontask"
|
|
3
3
|
require "rake/testtask"
|
|
4
|
-
require 'rake_compiler_dock'
|
|
5
|
-
require "rubygems/package_task"
|
|
6
|
-
require "bundler"
|
|
7
4
|
|
|
8
5
|
CROSS_PLATFORMS = %w[
|
|
9
6
|
aarch64-linux
|
|
7
|
+
aarch64-linux-musl
|
|
10
8
|
arm64-darwin
|
|
11
9
|
x64-mingw-ucrt
|
|
12
10
|
x86_64-darwin
|
|
@@ -18,9 +16,7 @@ spec = Bundler.load_gemspec("typst.gemspec")
|
|
|
18
16
|
|
|
19
17
|
Gem::PackageTask.new(spec).define
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Rake::ExtensionTask.new("typst", spec) do |ext|
|
|
19
|
+
RbSys::ExtensionTask.new("typst", spec) do |ext|
|
|
24
20
|
ext.lib_dir = "lib/typst"
|
|
25
21
|
ext.source_pattern = "*.{rs,toml}"
|
|
26
22
|
ext.cross_compile = true
|
data/ext/typst/Cargo.toml
CHANGED
|
@@ -21,13 +21,11 @@ filetime = "0.2.22" #
|
|
|
21
21
|
flate2 = "1" #
|
|
22
22
|
fontdb = "0.15.0" #
|
|
23
23
|
log = "0.4.20" #
|
|
24
|
-
magnus = { version = "0.
|
|
24
|
+
magnus = { version = "0.8.2" }
|
|
25
25
|
pathdiff = "0.2"
|
|
26
26
|
same-file = "1" #
|
|
27
27
|
siphasher = "1.0" #
|
|
28
28
|
tar = "0.4" #
|
|
29
|
-
#typst = { git = "https://github.com/typst/typst.git", tag = "v0.13.0" }
|
|
30
|
-
#typst-library = { git = "https://github.com/typst/typst.git", tag = "v0.13.0" }
|
|
31
29
|
serde = { version = "1.0.228", features = ["derive"] }
|
|
32
30
|
serde_json = "1"
|
|
33
31
|
serde_yaml = "0.9"
|
|
@@ -51,4 +49,4 @@ walkdir = "2.4.0"
|
|
|
51
49
|
|
|
52
50
|
# enable rb-sys feature to test against Ruby head. This is only needed if you
|
|
53
51
|
# want to work with the unreleased, in-development, next version of Ruby
|
|
54
|
-
rb-sys = { version = "0.9.
|
|
52
|
+
rb-sys = { version = "0.9.123", default-features = false, features = ["stable-api-compiled-fallback"] }
|
data/ext/typst/src/lib.rs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
use std::path::PathBuf;
|
|
2
2
|
|
|
3
|
-
use magnus::{
|
|
4
|
-
use magnus::{prelude::*};
|
|
3
|
+
use magnus::{function, prelude::*, Error, Ruby};
|
|
5
4
|
|
|
6
5
|
use std::collections::HashMap;
|
|
7
6
|
use query::{query as typst_query, QueryCommand, SerializationFormat};
|
|
@@ -15,6 +14,7 @@ mod query;
|
|
|
15
14
|
mod world;
|
|
16
15
|
|
|
17
16
|
fn to_html(
|
|
17
|
+
ruby: &Ruby,
|
|
18
18
|
input: PathBuf,
|
|
19
19
|
root: Option<PathBuf>,
|
|
20
20
|
font_paths: Vec<PathBuf>,
|
|
@@ -23,11 +23,11 @@ fn to_html(
|
|
|
23
23
|
sys_inputs: HashMap<String, String>,
|
|
24
24
|
) -> Result<Vec<Vec<u8>>, Error> {
|
|
25
25
|
let input = input.canonicalize()
|
|
26
|
-
.map_err(|err| magnus::Error::new(
|
|
26
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?;
|
|
27
27
|
|
|
28
28
|
let root = if let Some(root) = root {
|
|
29
29
|
root.canonicalize()
|
|
30
|
-
.map_err(|err| magnus::Error::new(
|
|
30
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?
|
|
31
31
|
} else if let Some(dir) = input.parent() {
|
|
32
32
|
dir.into()
|
|
33
33
|
} else {
|
|
@@ -35,12 +35,12 @@ fn to_html(
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
let resource_path = resource_path.canonicalize()
|
|
38
|
-
.map_err(|err| magnus::Error::new(
|
|
38
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?;
|
|
39
39
|
|
|
40
40
|
let mut default_fonts = Vec::new();
|
|
41
41
|
for entry in walkdir::WalkDir::new(resource_path.join("fonts")) {
|
|
42
42
|
let path = entry
|
|
43
|
-
.map_err(|err| magnus::Error::new(
|
|
43
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?
|
|
44
44
|
.into_path();
|
|
45
45
|
let Some(extension) = path.extension() else {
|
|
46
46
|
continue;
|
|
@@ -72,16 +72,17 @@ fn to_html(
|
|
|
72
72
|
.font_paths(font_paths)
|
|
73
73
|
.ignore_system_fonts(ignore_system_fonts)
|
|
74
74
|
.build()
|
|
75
|
-
.map_err(|msg| magnus::Error::new(
|
|
75
|
+
.map_err(|msg| magnus::Error::new(ruby.exception_arg_error(), msg.to_string()))?;
|
|
76
76
|
|
|
77
77
|
let bytes = world
|
|
78
78
|
.compile(Some("html"), None, &Vec::new())
|
|
79
|
-
.map_err(|msg| magnus::Error::new(
|
|
79
|
+
.map_err(|msg| magnus::Error::new(ruby.exception_arg_error(), msg.to_string()))?;
|
|
80
80
|
|
|
81
81
|
Ok(bytes)
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
fn to_svg(
|
|
85
|
+
ruby: &Ruby,
|
|
85
86
|
input: PathBuf,
|
|
86
87
|
root: Option<PathBuf>,
|
|
87
88
|
font_paths: Vec<PathBuf>,
|
|
@@ -90,11 +91,11 @@ fn to_svg(
|
|
|
90
91
|
sys_inputs: HashMap<String, String>,
|
|
91
92
|
) -> Result<Vec<Vec<u8>>, Error> {
|
|
92
93
|
let input = input.canonicalize()
|
|
93
|
-
.map_err(|err| magnus::Error::new(
|
|
94
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?;
|
|
94
95
|
|
|
95
96
|
let root = if let Some(root) = root {
|
|
96
97
|
root.canonicalize()
|
|
97
|
-
.map_err(|err| magnus::Error::new(
|
|
98
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?
|
|
98
99
|
} else if let Some(dir) = input.parent() {
|
|
99
100
|
dir.into()
|
|
100
101
|
} else {
|
|
@@ -102,12 +103,12 @@ fn to_svg(
|
|
|
102
103
|
};
|
|
103
104
|
|
|
104
105
|
let resource_path = resource_path.canonicalize()
|
|
105
|
-
.map_err(|err| magnus::Error::new(
|
|
106
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?;
|
|
106
107
|
|
|
107
108
|
let mut default_fonts = Vec::new();
|
|
108
109
|
for entry in walkdir::WalkDir::new(resource_path.join("fonts")) {
|
|
109
110
|
let path = entry
|
|
110
|
-
.map_err(|err| magnus::Error::new(
|
|
111
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?
|
|
111
112
|
.into_path();
|
|
112
113
|
let Some(extension) = path.extension() else {
|
|
113
114
|
continue;
|
|
@@ -126,16 +127,17 @@ fn to_svg(
|
|
|
126
127
|
.font_paths(font_paths)
|
|
127
128
|
.ignore_system_fonts(ignore_system_fonts)
|
|
128
129
|
.build()
|
|
129
|
-
.map_err(|msg| magnus::Error::new(
|
|
130
|
+
.map_err(|msg| magnus::Error::new(ruby.exception_arg_error(), msg.to_string()))?;
|
|
130
131
|
|
|
131
132
|
let svg_bytes = world
|
|
132
133
|
.compile(Some("svg"), None, &Vec::new())
|
|
133
|
-
.map_err(|msg| magnus::Error::new(
|
|
134
|
+
.map_err(|msg| magnus::Error::new(ruby.exception_arg_error(), msg.to_string()))?;
|
|
134
135
|
|
|
135
136
|
Ok(svg_bytes)
|
|
136
137
|
}
|
|
137
138
|
|
|
138
139
|
fn to_png(
|
|
140
|
+
ruby: &Ruby,
|
|
139
141
|
input: PathBuf,
|
|
140
142
|
root: Option<PathBuf>,
|
|
141
143
|
font_paths: Vec<PathBuf>,
|
|
@@ -144,11 +146,11 @@ fn to_png(
|
|
|
144
146
|
sys_inputs: HashMap<String, String>,
|
|
145
147
|
) -> Result<Vec<Vec<u8>>, Error> {
|
|
146
148
|
let input = input.canonicalize()
|
|
147
|
-
.map_err(|err| magnus::Error::new(
|
|
149
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?;
|
|
148
150
|
|
|
149
151
|
let root = if let Some(root) = root {
|
|
150
152
|
root.canonicalize()
|
|
151
|
-
.map_err(|err| magnus::Error::new(
|
|
153
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?
|
|
152
154
|
} else if let Some(dir) = input.parent() {
|
|
153
155
|
dir.into()
|
|
154
156
|
} else {
|
|
@@ -156,12 +158,12 @@ fn to_png(
|
|
|
156
158
|
};
|
|
157
159
|
|
|
158
160
|
let resource_path = resource_path.canonicalize()
|
|
159
|
-
.map_err(|err| magnus::Error::new(
|
|
161
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?;
|
|
160
162
|
|
|
161
163
|
let mut default_fonts = Vec::new();
|
|
162
164
|
for entry in walkdir::WalkDir::new(resource_path.join("fonts")) {
|
|
163
165
|
let path = entry
|
|
164
|
-
.map_err(|err| magnus::Error::new(
|
|
166
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?
|
|
165
167
|
.into_path();
|
|
166
168
|
let Some(extension) = path.extension() else {
|
|
167
169
|
continue;
|
|
@@ -180,16 +182,17 @@ fn to_png(
|
|
|
180
182
|
.font_paths(font_paths)
|
|
181
183
|
.ignore_system_fonts(ignore_system_fonts)
|
|
182
184
|
.build()
|
|
183
|
-
.map_err(|msg| magnus::Error::new(
|
|
185
|
+
.map_err(|msg| magnus::Error::new(ruby.exception_arg_error(), msg.to_string()))?;
|
|
184
186
|
|
|
185
187
|
let bytes = world
|
|
186
188
|
.compile(Some("png"), None, &Vec::new())
|
|
187
|
-
.map_err(|msg| magnus::Error::new(
|
|
189
|
+
.map_err(|msg| magnus::Error::new(ruby.exception_arg_error(), msg.to_string()))?;
|
|
188
190
|
|
|
189
191
|
Ok(bytes)
|
|
190
192
|
}
|
|
191
193
|
|
|
192
194
|
fn to_pdf(
|
|
195
|
+
ruby: &Ruby,
|
|
193
196
|
input: PathBuf,
|
|
194
197
|
root: Option<PathBuf>,
|
|
195
198
|
font_paths: Vec<PathBuf>,
|
|
@@ -198,11 +201,11 @@ fn to_pdf(
|
|
|
198
201
|
sys_inputs: HashMap<String, String>,
|
|
199
202
|
) -> Result<Vec<Vec<u8>>, Error> {
|
|
200
203
|
let input = input.canonicalize()
|
|
201
|
-
.map_err(|err| magnus::Error::new(
|
|
204
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?;
|
|
202
205
|
|
|
203
206
|
let root = if let Some(root) = root {
|
|
204
207
|
root.canonicalize()
|
|
205
|
-
.map_err(|err| magnus::Error::new(
|
|
208
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?
|
|
206
209
|
} else if let Some(dir) = input.parent() {
|
|
207
210
|
dir.into()
|
|
208
211
|
} else {
|
|
@@ -210,12 +213,12 @@ fn to_pdf(
|
|
|
210
213
|
};
|
|
211
214
|
|
|
212
215
|
let resource_path = resource_path.canonicalize()
|
|
213
|
-
.map_err(|err| magnus::Error::new(
|
|
216
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?;
|
|
214
217
|
|
|
215
218
|
let mut default_fonts = Vec::new();
|
|
216
219
|
for entry in walkdir::WalkDir::new(resource_path.join("fonts")) {
|
|
217
220
|
let path = entry
|
|
218
|
-
.map_err(|err| magnus::Error::new(
|
|
221
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?
|
|
219
222
|
.into_path();
|
|
220
223
|
let Some(extension) = path.extension() else {
|
|
221
224
|
continue;
|
|
@@ -234,16 +237,17 @@ fn to_pdf(
|
|
|
234
237
|
.font_paths(font_paths)
|
|
235
238
|
.ignore_system_fonts(ignore_system_fonts)
|
|
236
239
|
.build()
|
|
237
|
-
.map_err(|msg| magnus::Error::new(
|
|
240
|
+
.map_err(|msg| magnus::Error::new(ruby.exception_arg_error(), msg.to_string()))?;
|
|
238
241
|
|
|
239
242
|
let pdf_bytes = world
|
|
240
243
|
.compile(Some("pdf"), None, &Vec::new())
|
|
241
|
-
.map_err(|msg| magnus::Error::new(
|
|
244
|
+
.map_err(|msg| magnus::Error::new(ruby.exception_arg_error(), msg.to_string()))?;
|
|
242
245
|
|
|
243
246
|
Ok(pdf_bytes)
|
|
244
247
|
}
|
|
245
248
|
|
|
246
249
|
fn query(
|
|
250
|
+
ruby: &Ruby,
|
|
247
251
|
selector: String,
|
|
248
252
|
field: Option<String>,
|
|
249
253
|
one: bool,
|
|
@@ -258,15 +262,15 @@ fn query(
|
|
|
258
262
|
let format = match format.unwrap().to_ascii_lowercase().as_str() {
|
|
259
263
|
"json" => SerializationFormat::Json,
|
|
260
264
|
"yaml" => SerializationFormat::Yaml,
|
|
261
|
-
_ => return Err(magnus::Error::new(
|
|
265
|
+
_ => return Err(magnus::Error::new(ruby.exception_arg_error(), "unsupported serialization format"))?,
|
|
262
266
|
};
|
|
263
267
|
|
|
264
268
|
let input = input.canonicalize()
|
|
265
|
-
.map_err(|err| magnus::Error::new(
|
|
269
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?;
|
|
266
270
|
|
|
267
271
|
let root = if let Some(root) = root {
|
|
268
272
|
root.canonicalize()
|
|
269
|
-
.map_err(|err| magnus::Error::new(
|
|
273
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?
|
|
270
274
|
} else if let Some(dir) = input.parent() {
|
|
271
275
|
dir.into()
|
|
272
276
|
} else {
|
|
@@ -274,12 +278,12 @@ fn query(
|
|
|
274
278
|
};
|
|
275
279
|
|
|
276
280
|
let resource_path = resource_path.canonicalize()
|
|
277
|
-
.map_err(|err| magnus::Error::new(
|
|
281
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?;
|
|
278
282
|
|
|
279
283
|
let mut default_fonts = Vec::new();
|
|
280
284
|
for entry in walkdir::WalkDir::new(resource_path.join("fonts")) {
|
|
281
285
|
let path = entry
|
|
282
|
-
.map_err(|err| magnus::Error::new(
|
|
286
|
+
.map_err(|err| magnus::Error::new(ruby.exception_arg_error(), err.to_string()))?
|
|
283
287
|
.into_path();
|
|
284
288
|
let Some(extension) = path.extension() else {
|
|
285
289
|
continue;
|
|
@@ -298,7 +302,7 @@ fn query(
|
|
|
298
302
|
.font_paths(font_paths)
|
|
299
303
|
.ignore_system_fonts(ignore_system_fonts)
|
|
300
304
|
.build()
|
|
301
|
-
.map_err(|msg| magnus::Error::new(
|
|
305
|
+
.map_err(|msg| magnus::Error::new(ruby.exception_arg_error(), msg.to_string()))?;
|
|
302
306
|
|
|
303
307
|
let result = typst_query(
|
|
304
308
|
&mut world,
|
|
@@ -312,15 +316,15 @@ fn query(
|
|
|
312
316
|
|
|
313
317
|
match result {
|
|
314
318
|
Ok(data) => Ok(data),
|
|
315
|
-
Err(msg) => Err(magnus::Error::new(
|
|
319
|
+
Err(msg) => Err(magnus::Error::new(ruby.exception_arg_error(), msg.to_string())),
|
|
316
320
|
}
|
|
317
321
|
}
|
|
318
322
|
|
|
319
323
|
#[magnus::init]
|
|
320
|
-
fn init() -> Result<(), Error> {
|
|
324
|
+
fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
321
325
|
env_logger::init();
|
|
322
326
|
|
|
323
|
-
let module = define_module("Typst")?;
|
|
327
|
+
let module = ruby.define_module("Typst")?;
|
|
324
328
|
module.define_singleton_method("_to_pdf", function!(to_pdf, 6))?;
|
|
325
329
|
module.define_singleton_method("_to_svg", function!(to_svg, 6))?;
|
|
326
330
|
module.define_singleton_method("_to_png", function!(to_png, 6))?;
|
data/lib/typst/typst.bundle
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: typst
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.14.2
|
|
4
|
+
version: 0.14.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Flinn
|
|
@@ -18,7 +18,7 @@ dependencies:
|
|
|
18
18
|
version: '0.9'
|
|
19
19
|
- - ">="
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: 0.9.
|
|
21
|
+
version: 0.9.123
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -28,7 +28,7 @@ dependencies:
|
|
|
28
28
|
version: '0.9'
|
|
29
29
|
- - ">="
|
|
30
30
|
- !ruby/object:Gem::Version
|
|
31
|
-
version: 0.9.
|
|
31
|
+
version: 0.9.123
|
|
32
32
|
- !ruby/object:Gem::Dependency
|
|
33
33
|
name: rubyzip
|
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -114,7 +114,6 @@ files:
|
|
|
114
114
|
- lib/query.rb
|
|
115
115
|
- lib/typst.rb
|
|
116
116
|
- lib/typst/typst.bundle
|
|
117
|
-
- lib/typst/typst.so
|
|
118
117
|
homepage: https://github.com/actsasflinn/typst-rb
|
|
119
118
|
licenses:
|
|
120
119
|
- Apache-2.0
|
|
@@ -133,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
133
132
|
- !ruby/object:Gem::Version
|
|
134
133
|
version: '0'
|
|
135
134
|
requirements: []
|
|
136
|
-
rubygems_version: 3.6.
|
|
135
|
+
rubygems_version: 3.6.9
|
|
137
136
|
specification_version: 4
|
|
138
137
|
summary: Ruby binding to typst, a new markup-based typesetting system that is powerful
|
|
139
138
|
and easy to learn.
|
data/lib/typst/typst.so
DELETED
|
Binary file
|