typst 0.13.3-arm64-darwin-23

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,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: typst
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.13.3
5
+ platform: arm64-darwin-23
6
+ authors:
7
+ - Flinn
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rb_sys
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 0.9.83
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
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'
54
+ email: flinn@actsasflinn.com
55
+ executables: []
56
+ extensions: []
57
+ extra_rdoc_files: []
58
+ files:
59
+ - Cargo.toml
60
+ - README.md
61
+ - README.typ
62
+ - Rakefile
63
+ - ext/typst/Cargo.toml
64
+ - ext/typst/extconf.rb
65
+ - ext/typst/src/compiler-new.rs
66
+ - ext/typst/src/compiler.rs
67
+ - ext/typst/src/download.rs
68
+ - ext/typst/src/fonts.rs
69
+ - ext/typst/src/lib.rs
70
+ - ext/typst/src/package.rs
71
+ - ext/typst/src/query.rs
72
+ - ext/typst/src/world.rs
73
+ - lib/base.rb
74
+ - lib/document.rb
75
+ - lib/fonts/DejaVuSansMono-Bold.ttf
76
+ - lib/fonts/DejaVuSansMono-BoldOblique.ttf
77
+ - lib/fonts/DejaVuSansMono-Oblique.ttf
78
+ - lib/fonts/DejaVuSansMono.ttf
79
+ - lib/fonts/LinLibertine_R.ttf
80
+ - lib/fonts/LinLibertine_RB.ttf
81
+ - lib/fonts/LinLibertine_RBI.ttf
82
+ - lib/fonts/LinLibertine_RI.ttf
83
+ - lib/fonts/NewCM10-Bold.otf
84
+ - lib/fonts/NewCM10-BoldItalic.otf
85
+ - lib/fonts/NewCM10-Italic.otf
86
+ - lib/fonts/NewCM10-Regular.otf
87
+ - lib/fonts/NewCMMath-Book.otf
88
+ - lib/fonts/NewCMMath-Regular.otf
89
+ - lib/formats/html.rb
90
+ - lib/formats/html_experimental.rb
91
+ - lib/formats/pdf.rb
92
+ - lib/formats/png.rb
93
+ - lib/formats/svg.rb
94
+ - lib/query.rb
95
+ - lib/typst.rb
96
+ - lib/typst/typst.bundle
97
+ homepage: https://github.com/actsasflinn/typst-rb
98
+ licenses:
99
+ - Apache-2.0
100
+ metadata: {}
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '3.4'
109
+ - - "<"
110
+ - !ruby/object:Gem::Version
111
+ version: 3.5.dev
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubygems_version: 3.6.9
119
+ specification_version: 4
120
+ summary: Ruby binding to typst, a new markup-based typesetting system that is powerful
121
+ and easy to learn.
122
+ test_files: []