typst 0.13.0 → 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.
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, {})[0]
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, {}).collect{ |page| page.pack("C*").to_s }
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, {}).collect{ |page| page.pack("C*").to_s }
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, {})[0]
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.0
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: 2025-02-23 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rb_sys
@@ -23,6 +23,34 @@ dependencies:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
25
  version: 0.9.83
26
+ - !ruby/object:Gem::Dependency
27
+ name: rubyzip
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.4'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
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'
26
54
  email: flinn@actsasflinn.com
27
55
  executables: []
28
56
  extensions:
@@ -33,9 +61,9 @@ files:
33
61
  - README.md
34
62
  - README.typ
35
63
  - Rakefile
36
- - ext/typst/Cargo.lock
37
64
  - ext/typst/Cargo.toml
38
65
  - ext/typst/extconf.rb
66
+ - ext/typst/src/compiler-new.rs
39
67
  - ext/typst/src/compiler.rs
40
68
  - ext/typst/src/download.rs
41
69
  - ext/typst/src/fonts.rs
@@ -76,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
104
  - !ruby/object:Gem::Version
77
105
  version: '0'
78
106
  requirements: []
79
- rubygems_version: 3.6.3
107
+ rubygems_version: 3.6.8
80
108
  specification_version: 4
81
109
  summary: Ruby binding to typst, a new markup-based typesetting system that is powerful
82
110
  and easy to learn.