typst 0.13.5-x64-mingw-ucrt

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.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/Cargo.toml +3 -0
  3. data/README.md +133 -0
  4. data/README.typ +136 -0
  5. data/Rakefile +51 -0
  6. data/ext/typst/Cargo.toml +54 -0
  7. data/ext/typst/extconf.rb +4 -0
  8. data/ext/typst/src/compiler-new.rs +771 -0
  9. data/ext/typst/src/compiler.rs +248 -0
  10. data/ext/typst/src/download.rs +19 -0
  11. data/ext/typst/src/fonts.rs +86 -0
  12. data/ext/typst/src/lib.rs +330 -0
  13. data/ext/typst/src/package.rs +64 -0
  14. data/ext/typst/src/query.rs +131 -0
  15. data/ext/typst/src/world.rs +351 -0
  16. data/lib/base.rb +169 -0
  17. data/lib/document.rb +29 -0
  18. data/lib/fonts/DejaVuSansMono-Bold.ttf +0 -0
  19. data/lib/fonts/DejaVuSansMono-BoldOblique.ttf +0 -0
  20. data/lib/fonts/DejaVuSansMono-Oblique.ttf +0 -0
  21. data/lib/fonts/DejaVuSansMono.ttf +0 -0
  22. data/lib/fonts/LinLibertine_R.ttf +0 -0
  23. data/lib/fonts/LinLibertine_RB.ttf +0 -0
  24. data/lib/fonts/LinLibertine_RBI.ttf +0 -0
  25. data/lib/fonts/LinLibertine_RI.ttf +0 -0
  26. data/lib/fonts/NewCM10-Bold.otf +0 -0
  27. data/lib/fonts/NewCM10-BoldItalic.otf +0 -0
  28. data/lib/fonts/NewCM10-Italic.otf +0 -0
  29. data/lib/fonts/NewCM10-Regular.otf +0 -0
  30. data/lib/fonts/NewCMMath-Book.otf +0 -0
  31. data/lib/fonts/NewCMMath-Regular.otf +0 -0
  32. data/lib/formats/html.rb +35 -0
  33. data/lib/formats/html_experimental.rb +11 -0
  34. data/lib/formats/pdf.rb +11 -0
  35. data/lib/formats/png.rb +11 -0
  36. data/lib/formats/svg.rb +11 -0
  37. data/lib/query.rb +19 -0
  38. data/lib/typst/3.1/typst.so +0 -0
  39. data/lib/typst/3.2/typst.so +0 -0
  40. data/lib/typst/3.3/typst.so +0 -0
  41. data/lib/typst/3.4/typst.so +0 -0
  42. data/lib/typst.rb +38 -0
  43. metadata +143 -0
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
Binary file
Binary file
Binary file
data/lib/typst.rb ADDED
@@ -0,0 +1,38 @@
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
+ begin
24
+ # native precompiled gems package shared libraries in <gem_dir>/lib/typst/<ruby_version>
25
+ RUBY_VERSION =~ /(\d+\.\d+)/
26
+ require_relative "typst/#{Regexp.last_match(1)}/typst"
27
+ rescue LoadError => e
28
+ require_relative "typst/typst"
29
+ end
30
+
31
+ require_relative "base"
32
+ require_relative "query"
33
+ require_relative "document"
34
+ require_relative "formats/pdf"
35
+ require_relative "formats/svg"
36
+ require_relative "formats/png"
37
+ require_relative "formats/html"
38
+ require_relative "formats/html_experimental"
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: typst
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.13.5
5
+ platform: x64-mingw-ucrt
6
+ authors:
7
+ - Flinn
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-06-28 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.116
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.116
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: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.6'
69
+ description:
70
+ email: flinn@actsasflinn.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - Cargo.toml
76
+ - README.md
77
+ - README.typ
78
+ - Rakefile
79
+ - ext/typst/Cargo.toml
80
+ - ext/typst/extconf.rb
81
+ - ext/typst/src/compiler-new.rs
82
+ - ext/typst/src/compiler.rs
83
+ - ext/typst/src/download.rs
84
+ - ext/typst/src/fonts.rs
85
+ - ext/typst/src/lib.rs
86
+ - ext/typst/src/package.rs
87
+ - ext/typst/src/query.rs
88
+ - ext/typst/src/world.rs
89
+ - lib/base.rb
90
+ - lib/document.rb
91
+ - lib/fonts/DejaVuSansMono-Bold.ttf
92
+ - lib/fonts/DejaVuSansMono-BoldOblique.ttf
93
+ - lib/fonts/DejaVuSansMono-Oblique.ttf
94
+ - lib/fonts/DejaVuSansMono.ttf
95
+ - lib/fonts/LinLibertine_R.ttf
96
+ - lib/fonts/LinLibertine_RB.ttf
97
+ - lib/fonts/LinLibertine_RBI.ttf
98
+ - lib/fonts/LinLibertine_RI.ttf
99
+ - lib/fonts/NewCM10-Bold.otf
100
+ - lib/fonts/NewCM10-BoldItalic.otf
101
+ - lib/fonts/NewCM10-Italic.otf
102
+ - lib/fonts/NewCM10-Regular.otf
103
+ - lib/fonts/NewCMMath-Book.otf
104
+ - lib/fonts/NewCMMath-Regular.otf
105
+ - lib/formats/html.rb
106
+ - lib/formats/html_experimental.rb
107
+ - lib/formats/pdf.rb
108
+ - lib/formats/png.rb
109
+ - lib/formats/svg.rb
110
+ - lib/query.rb
111
+ - lib/typst.rb
112
+ - lib/typst/3.1/typst.so
113
+ - lib/typst/3.2/typst.so
114
+ - lib/typst/3.3/typst.so
115
+ - lib/typst/3.4/typst.so
116
+ homepage: https://github.com/actsasflinn/typst-rb
117
+ licenses:
118
+ - Apache-2.0
119
+ metadata: {}
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '3.1'
129
+ - - "<"
130
+ - !ruby/object:Gem::Version
131
+ version: 3.5.dev
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubygems_version: 3.5.23
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Ruby binding to typst, a new markup-based typesetting system that is powerful
142
+ and easy to learn.
143
+ test_files: []