typst 0.15.1.2 → 0.15.1.5
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 +3 -1
- data/README.typ +3 -1
- data/Rakefile +5 -0
- data/ext/typst/src/compiler.rs +10 -5
- data/ext/typst/src/lib.rs +10 -7
- data/lib/base.rb +9 -6
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a463fc66211965514d27ea8a2867902818e7f4398779b79a4c304a993e4d5e63
|
|
4
|
+
data.tar.gz: 484a1cdbecc7ae9381d7de90313a82b0288f053dd7a105974dc80f82d0baa4e3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 930e9e74d5cd98a50c7f06c181f4104b5ef9325a43008e9b114ae7006b4d13b2445ea57c27c28c3d60f2df5ee07c0734ea2047f52e494c4303df917058a0feed
|
|
7
|
+
data.tar.gz: 0e806b7acb6b404e92ae170ce0f78f86743ca56dd99d99f5e365bd62a0f154bb7aebf8efadf4977260a85872325d4055aadde543df199dfa582b8aa07635caf8
|
data/README.md
CHANGED
|
@@ -194,7 +194,9 @@ Typst::clear_cache(max_age)
|
|
|
194
194
|
## Contributors & Acknowledgements
|
|
195
195
|
typst-rb is based on [typst-py](https://github.com/messense/typst-py) by [messense](https://github.com/messense)\
|
|
196
196
|
clear_cache was contributed by [NRicciVestmark](https://github.com/NRicciVestmark)\
|
|
197
|
-
CI improvements were contributed by [am1006](https://github.com/am1006)
|
|
197
|
+
CI improvements were contributed by [am1006](https://github.com/am1006)\
|
|
198
|
+
Defect resolutions by [adam12](https://github.com/adam12) and [walterdavis](https://github.com/walterdavis)\
|
|
199
|
+
Design suggestions by [alec-c4](https://github.com/alec-c4)
|
|
198
200
|
|
|
199
201
|
## License
|
|
200
202
|
|
data/README.typ
CHANGED
|
@@ -202,7 +202,9 @@ Typst::clear_cache(max_age)
|
|
|
202
202
|
== Contributors & Acknowledgements
|
|
203
203
|
typst-rb is based on #link("https://github.com/messense/typst-py")[typst-py] by #link("https://github.com/messense")[messense]\
|
|
204
204
|
clear_cache was contributed by #link("https://github.com/NRicciVestmark")[NRicciVestmark]\
|
|
205
|
-
CI improvements were contributed by #link("https://github.com/am1006")[am1006]
|
|
205
|
+
CI improvements were contributed by #link("https://github.com/am1006")[am1006]\
|
|
206
|
+
Defect resolutions by #link("https://github.com/adam12")[adam12] and #link("https://github.com/walterdavis")[walterdavis]\
|
|
207
|
+
Design suggestions by #link("https://github.com/alec-c4")[alec-c4]
|
|
206
208
|
|
|
207
209
|
== License
|
|
208
210
|
|
data/Rakefile
CHANGED
|
@@ -23,6 +23,11 @@ RbSys::ExtensionTask.new("typst", spec) do |ext|
|
|
|
23
23
|
ext.cross_platform = CROSS_PLATFORMS
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
Rake::Task['release'].clear
|
|
27
|
+
desc "Create tag #{spec.version} and build"
|
|
28
|
+
task "release", [:remote] => ["build", "release:guard_clean", "release:source_control_push"] do
|
|
29
|
+
end
|
|
30
|
+
|
|
26
31
|
Rake::TestTask.new do |t|
|
|
27
32
|
t.libs << "test"
|
|
28
33
|
t.test_files = FileList['test/*_test.rb']
|
data/ext/typst/src/compiler.rs
CHANGED
|
@@ -21,6 +21,7 @@ impl SystemWorld {
|
|
|
21
21
|
ppi: Option<f32>,
|
|
22
22
|
pdf_standards: &[typst_pdf::PdfStandard],
|
|
23
23
|
pretty: bool,
|
|
24
|
+
render_bleed: bool,
|
|
24
25
|
) -> StrResult<Vec<Vec<u8>>> {
|
|
25
26
|
// Reset everything and ensure that the main file is present.
|
|
26
27
|
self.reset();
|
|
@@ -49,10 +50,10 @@ impl SystemWorld {
|
|
|
49
50
|
typst_pdf::PdfStandards::new(pdf_standards)
|
|
50
51
|
.map_err(|e| eco_format!("PDF standards error: {:?}", e))
|
|
51
52
|
.at(Span::detached()).unwrap(),
|
|
52
|
-
pretty
|
|
53
|
+
pretty,
|
|
53
54
|
)?]),
|
|
54
|
-
"png" => Ok(export_image(&document, ImageExportFormat::Png, ppi, pretty)?),
|
|
55
|
-
"svg" => Ok(export_image(&document, ImageExportFormat::Svg, ppi, pretty)?),
|
|
55
|
+
"png" => Ok(export_image(&document, ImageExportFormat::Png, ppi, pretty, render_bleed)?),
|
|
56
|
+
"svg" => Ok(export_image(&document, ImageExportFormat::Svg, ppi, pretty, render_bleed)?),
|
|
56
57
|
fmt => Err(eco_format!("unknown format: {fmt}")),
|
|
57
58
|
}
|
|
58
59
|
}
|
|
@@ -129,6 +130,7 @@ fn export_image(
|
|
|
129
130
|
fmt: ImageExportFormat,
|
|
130
131
|
ppi: Option<f32>,
|
|
131
132
|
pretty: bool,
|
|
133
|
+
render_bleed: bool,
|
|
132
134
|
) -> StrResult<Vec<Vec<u8>>> {
|
|
133
135
|
let mut buffers = Vec::new();
|
|
134
136
|
for page in document.pages() {
|
|
@@ -137,13 +139,16 @@ fn export_image(
|
|
|
137
139
|
page,
|
|
138
140
|
&typst_render::RenderOptions {
|
|
139
141
|
pixel_per_pt: typst::utils::Scalar::new(f64::from(ppi.unwrap_or(144.0) / 72.0)),
|
|
140
|
-
render_bleed:
|
|
142
|
+
render_bleed: render_bleed,
|
|
141
143
|
},
|
|
142
144
|
)
|
|
143
145
|
.encode_png()
|
|
144
146
|
.map_err(|err| eco_format!("failed to write PNG file ({err})"))?,
|
|
145
147
|
ImageExportFormat::Svg => {
|
|
146
|
-
let svg = typst_svg::svg(
|
|
148
|
+
let svg = typst_svg::svg(
|
|
149
|
+
page,
|
|
150
|
+
&typst_svg::SvgOptions{ render_bleed: render_bleed, pretty: pretty }
|
|
151
|
+
);
|
|
147
152
|
svg.as_bytes().to_vec()
|
|
148
153
|
}
|
|
149
154
|
};
|
data/ext/typst/src/lib.rs
CHANGED
|
@@ -21,6 +21,7 @@ fn to_html(
|
|
|
21
21
|
font_paths: Vec<PathBuf>,
|
|
22
22
|
ignore_system_fonts: bool,
|
|
23
23
|
ignore_embedded_fonts: bool,
|
|
24
|
+
render_bleed: bool,
|
|
24
25
|
pretty: bool,
|
|
25
26
|
sys_inputs: HashMap<String, String>,
|
|
26
27
|
) -> Result<Vec<Vec<u8>>, Error> {
|
|
@@ -62,7 +63,7 @@ fn to_html(
|
|
|
62
63
|
.map_err(|msg| magnus::Error::new(ruby.exception_arg_error(), msg.to_string()))?;
|
|
63
64
|
|
|
64
65
|
let bytes = world
|
|
65
|
-
.compile(Some("html"), None, &Vec::new(), pretty)
|
|
66
|
+
.compile(Some("html"), None, &Vec::new(), pretty, render_bleed)
|
|
66
67
|
.map_err(|msg| magnus::Error::new(ruby.exception_arg_error(), msg.to_string()))?;
|
|
67
68
|
|
|
68
69
|
Ok(bytes)
|
|
@@ -75,6 +76,7 @@ fn to_svg(
|
|
|
75
76
|
font_paths: Vec<PathBuf>,
|
|
76
77
|
ignore_system_fonts: bool,
|
|
77
78
|
ignore_embedded_fonts: bool,
|
|
79
|
+
render_bleed: bool,
|
|
78
80
|
pretty: bool,
|
|
79
81
|
sys_inputs: HashMap<String, String>,
|
|
80
82
|
) -> Result<Vec<Vec<u8>>, Error> {
|
|
@@ -103,7 +105,7 @@ fn to_svg(
|
|
|
103
105
|
.map_err(|msg| magnus::Error::new(ruby.exception_arg_error(), msg.to_string()))?;
|
|
104
106
|
|
|
105
107
|
let svg_bytes = world
|
|
106
|
-
.compile(Some("svg"), None, &Vec::new(), pretty)
|
|
108
|
+
.compile(Some("svg"), None, &Vec::new(), pretty, render_bleed)
|
|
107
109
|
.map_err(|msg| magnus::Error::new(ruby.exception_arg_error(), msg.to_string()))?;
|
|
108
110
|
|
|
109
111
|
Ok(svg_bytes)
|
|
@@ -116,6 +118,7 @@ fn to_png(
|
|
|
116
118
|
font_paths: Vec<PathBuf>,
|
|
117
119
|
ignore_system_fonts: bool,
|
|
118
120
|
ignore_embedded_fonts: bool,
|
|
121
|
+
render_bleed: bool,
|
|
119
122
|
sys_inputs: HashMap<String, String>,
|
|
120
123
|
ppi: Option<f32>,
|
|
121
124
|
) -> Result<Vec<Vec<u8>>, Error> {
|
|
@@ -144,7 +147,7 @@ fn to_png(
|
|
|
144
147
|
.map_err(|msg| magnus::Error::new(ruby.exception_arg_error(), msg.to_string()))?;
|
|
145
148
|
|
|
146
149
|
let bytes = world
|
|
147
|
-
.compile(Some("png"), ppi, &Vec::new(), false)
|
|
150
|
+
.compile(Some("png"), ppi, &Vec::new(), false, render_bleed)
|
|
148
151
|
.map_err(|msg| magnus::Error::new(ruby.exception_arg_error(), msg.to_string()))?;
|
|
149
152
|
|
|
150
153
|
Ok(bytes)
|
|
@@ -215,7 +218,7 @@ fn to_pdf(
|
|
|
215
218
|
}
|
|
216
219
|
|
|
217
220
|
let pdf_bytes = world
|
|
218
|
-
.compile(Some("pdf"), None, &pdf_standards_vec, pretty)
|
|
221
|
+
.compile(Some("pdf"), None, &pdf_standards_vec, pretty, true)
|
|
219
222
|
.map_err(|msg| magnus::Error::new(ruby.exception_arg_error(), msg.to_string()))?;
|
|
220
223
|
|
|
221
224
|
Ok(pdf_bytes)
|
|
@@ -290,9 +293,9 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
290
293
|
|
|
291
294
|
let module = ruby.define_module("Typst")?;
|
|
292
295
|
module.define_singleton_method("_to_pdf", function!(to_pdf, 8))?;
|
|
293
|
-
module.define_singleton_method("_to_svg", function!(to_svg,
|
|
294
|
-
module.define_singleton_method("_to_png", function!(to_png,
|
|
295
|
-
module.define_singleton_method("_to_html", function!(to_html,
|
|
296
|
+
module.define_singleton_method("_to_svg", function!(to_svg, 8))?;
|
|
297
|
+
module.define_singleton_method("_to_png", function!(to_png, 8))?;
|
|
298
|
+
module.define_singleton_method("_to_html", function!(to_html, 8))?;
|
|
296
299
|
module.define_singleton_method("_query", function!(query, 10))?;
|
|
297
300
|
module.define_singleton_method("_clear_cache", function!(clear_cache, 1))?;
|
|
298
301
|
Ok(())
|
data/lib/base.rb
CHANGED
|
@@ -37,29 +37,32 @@ module Typst
|
|
|
37
37
|
options[:ignore_system_fonts] ||= false
|
|
38
38
|
options[:ignore_embedded_fonts] ||= false
|
|
39
39
|
options[:pretty] ||= false
|
|
40
|
+
options[:render_bleed] ||= false
|
|
40
41
|
|
|
41
42
|
self.options = options
|
|
42
43
|
end
|
|
43
44
|
|
|
44
45
|
def typst_options
|
|
45
|
-
[:file, :root, :font_paths, :ignore_system_fonts, :ignore_embedded_fonts]
|
|
46
|
+
[:file, :root, :font_paths, :ignore_system_fonts, :ignore_embedded_fonts, :render_bleed]
|
|
46
47
|
end
|
|
47
48
|
|
|
48
|
-
def typst_args
|
|
49
|
-
options.values_at(*
|
|
49
|
+
def typst_args(opts)
|
|
50
|
+
options.values_at(*opts).append(options[:sys_inputs].map{ |k,v| [k.to_s,v.to_s] }.to_h)
|
|
50
51
|
end
|
|
51
52
|
|
|
52
53
|
def typst_pretty_args
|
|
53
|
-
|
|
54
|
+
typst_args(typst_options.append(:pretty))
|
|
54
55
|
end
|
|
55
56
|
|
|
56
57
|
def typst_pdf_args
|
|
57
58
|
options[:pdf_standards] ||= []
|
|
58
|
-
[
|
|
59
|
+
opts = typst_options - [:render_bleed] + [:pretty]
|
|
60
|
+
args = typst_args(opts)
|
|
61
|
+
[*args, options[:pdf_standards]]
|
|
59
62
|
end
|
|
60
63
|
|
|
61
64
|
def typst_png_args
|
|
62
|
-
[*typst_args, options[:ppi]]
|
|
65
|
+
[*typst_args(typst_options), options[:ppi]]
|
|
63
66
|
end
|
|
64
67
|
|
|
65
68
|
def self.from_s(main_source, **options)
|
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.15.1.
|
|
4
|
+
version: 0.15.1.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Flinn
|
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
117
117
|
- !ruby/object:Gem::Version
|
|
118
118
|
version: '0'
|
|
119
119
|
requirements: []
|
|
120
|
-
rubygems_version: 4.0.
|
|
120
|
+
rubygems_version: 4.0.17
|
|
121
121
|
specification_version: 4
|
|
122
122
|
summary: Ruby binding to typst, a new markup-based typesetting system that is powerful
|
|
123
123
|
and easy to learn.
|