typst 0.13.3-arm64-darwin

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/document.rb ADDED
@@ -0,0 +1,29 @@
1
+ module Typst
2
+ class Document
3
+ attr_accessor :bytes
4
+
5
+ def initialize(bytes)
6
+ @bytes = bytes
7
+ end
8
+
9
+ def write(out)
10
+ if pages.size == 1
11
+ File.write(out, pages.first, mode: "wb")
12
+ else
13
+ pages.each_with_index do |page, i|
14
+ fn = File.basename(out, ".*") + "_{{n}}" + File.extname(out) unless out.include?("{{n}}")
15
+ fn = fn.gsub("{{n}}", (i+1).to_s)
16
+ File.write(fn, page, mode: "wb")
17
+ end
18
+ end
19
+ end
20
+
21
+ def pages
22
+ bytes.collect{ |page| page.pack("C*").to_s }
23
+ end
24
+
25
+ def document
26
+ pages.size == 1 ? pages.first : pages
27
+ end
28
+ end
29
+ end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,35 @@
1
+ module Typst
2
+ class Html < Base
3
+ def initialize(*options)
4
+ super(*options)
5
+ title = CGI::escapeHTML(@options[:title] || File.basename(@options[:file], ".*"))
6
+ @compiled = HtmlDocument.new(Typst::_to_svg(*self.typst_args), title)
7
+ end
8
+ end
9
+
10
+ class HtmlDocument < Document
11
+ attr_accessor :title
12
+
13
+ def initialize(bytes, title)
14
+ super(bytes)
15
+ self.title = title
16
+ end
17
+
18
+ def markup
19
+ %{
20
+ <!DOCTYPE html>
21
+ <html>
22
+ <head>
23
+ <title>#{title}</title>
24
+ </head>
25
+ <body>
26
+ #{pages.join("<br />")}
27
+ </body>
28
+ </html>
29
+ }
30
+ end
31
+ alias_method :document, :markup
32
+ end
33
+
34
+ register_format(html: Html)
35
+ end
@@ -0,0 +1,11 @@
1
+ module Typst
2
+ class HtmlExperimental < Base
3
+ def initialize(*options)
4
+ super(*options)
5
+ @compiled = HtmlExperimentalDocument.new(Typst::_to_html(*self.typst_args))
6
+ end
7
+ end
8
+ class HtmlExperimentalDocument < Document; end
9
+
10
+ register_format(html_experimental: HtmlExperimental)
11
+ end
@@ -0,0 +1,11 @@
1
+ module Typst
2
+ class Pdf < Base
3
+ def initialize(*options)
4
+ super(*options)
5
+ @compiled = PdfDocument.new(Typst::_to_pdf(*self.typst_args))
6
+ end
7
+ end
8
+ class PdfDocument < Document; end
9
+
10
+ register_format(pdf: Pdf)
11
+ end
@@ -0,0 +1,11 @@
1
+ module Typst
2
+ class Png < Base
3
+ def initialize(*options)
4
+ super(*options)
5
+ @compiled = PngDocument.new(Typst::_to_png(*self.typst_args))
6
+ end
7
+ end
8
+ class PngDocument < Document; end
9
+
10
+ register_format(png: Png)
11
+ end
@@ -0,0 +1,11 @@
1
+ module Typst
2
+ class Svg < Base
3
+ def initialize(*options)
4
+ super(*options)
5
+ @compiled = SvgDocument.new(Typst::_to_svg(*self.typst_args))
6
+ end
7
+ end
8
+ class SvgDocument < Document; end
9
+
10
+ register_format(svg: Svg)
11
+ end
data/lib/query.rb ADDED
@@ -0,0 +1,19 @@
1
+ module Typst
2
+ class Query < Base
3
+ attr_accessor :format
4
+
5
+ def initialize(selector, input, field: nil, one: false, format: "json", root: ".", font_paths: [], sys_inputs: {})
6
+ super(input, root: root, font_paths: font_paths, sys_inputs: sys_inputs)
7
+ self.format = format
8
+ @result = Typst::_query(selector, field, one, format, input, root, font_paths, File.dirname(__FILE__), false, sys_inputs)
9
+ end
10
+
11
+ def result(raw: false)
12
+ case raw || format
13
+ when "json" then JSON(@result)
14
+ when "yaml" then YAML::safe_load(@result)
15
+ else @result
16
+ end
17
+ end
18
+ end
19
+ end
Binary file
data/lib/typst.rb ADDED
@@ -0,0 +1,31 @@
1
+ def Typst(*options)
2
+ Typst::Base.new(*options)
3
+ end
4
+
5
+ module Typst
6
+ @@formats = {}
7
+
8
+ def self.register_format(**format)
9
+ @@formats.merge!(format)
10
+ end
11
+
12
+ def self.formats
13
+ @@formats
14
+ end
15
+ end
16
+
17
+
18
+ require "cgi"
19
+ require "pathname"
20
+ require "tmpdir"
21
+ require "zip/filesystem"
22
+
23
+ require_relative "typst/typst"
24
+ require_relative "base"
25
+ require_relative "query"
26
+ require_relative "document"
27
+ require_relative "formats/pdf"
28
+ require_relative "formats/svg"
29
+ require_relative "formats/png"
30
+ require_relative "formats/html"
31
+ require_relative "formats/html_experimental"
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: typst
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.13.3
5
+ platform: arm64-darwin
6
+ authors:
7
+ - Flinn
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-05-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rb_sys
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.110
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.110
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubyzip
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: hexapdf
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email: flinn@actsasflinn.com
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - Cargo.toml
62
+ - README.md
63
+ - README.typ
64
+ - Rakefile
65
+ - ext/typst/Cargo.toml
66
+ - ext/typst/extconf.rb
67
+ - ext/typst/src/compiler-new.rs
68
+ - ext/typst/src/compiler.rs
69
+ - ext/typst/src/download.rs
70
+ - ext/typst/src/fonts.rs
71
+ - ext/typst/src/lib.rs
72
+ - ext/typst/src/package.rs
73
+ - ext/typst/src/query.rs
74
+ - ext/typst/src/world.rs
75
+ - lib/base.rb
76
+ - lib/document.rb
77
+ - lib/fonts/DejaVuSansMono-Bold.ttf
78
+ - lib/fonts/DejaVuSansMono-BoldOblique.ttf
79
+ - lib/fonts/DejaVuSansMono-Oblique.ttf
80
+ - lib/fonts/DejaVuSansMono.ttf
81
+ - lib/fonts/LinLibertine_R.ttf
82
+ - lib/fonts/LinLibertine_RB.ttf
83
+ - lib/fonts/LinLibertine_RBI.ttf
84
+ - lib/fonts/LinLibertine_RI.ttf
85
+ - lib/fonts/NewCM10-Bold.otf
86
+ - lib/fonts/NewCM10-BoldItalic.otf
87
+ - lib/fonts/NewCM10-Italic.otf
88
+ - lib/fonts/NewCM10-Regular.otf
89
+ - lib/fonts/NewCMMath-Book.otf
90
+ - lib/fonts/NewCMMath-Regular.otf
91
+ - lib/formats/html.rb
92
+ - lib/formats/html_experimental.rb
93
+ - lib/formats/pdf.rb
94
+ - lib/formats/png.rb
95
+ - lib/formats/svg.rb
96
+ - lib/query.rb
97
+ - lib/typst.rb
98
+ - lib/typst/typst.bundle
99
+ homepage: https://github.com/actsasflinn/typst-rb
100
+ licenses:
101
+ - Apache-2.0
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '3.4'
112
+ - - "<"
113
+ - !ruby/object:Gem::Version
114
+ version: 3.5.dev
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubygems_version: 3.5.23
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Ruby binding to typst, a new markup-based typesetting system that is powerful
125
+ and easy to learn.
126
+ test_files: []