Class: Typst::Html

Inherits:
Base
  • Object
show all
Defined in:
lib/typst.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#font_paths, #input, #root, #sys_inputs

Instance Method Summary collapse

Methods inherited from Base

from_s, from_zip, #write

Constructor Details

#initialize(input, title: nil, root: ".", font_paths: [], sys_inputs: {}) ⇒ Html



148
149
150
151
152
153
# File 'lib/typst.rb', line 148

def initialize(input, title: nil, root: ".", font_paths: [], sys_inputs: {})
  super(input, root: root, font_paths: font_paths, sys_inputs: sys_inputs)
  title = title || File.basename(input, File.extname(input))
  self.title = CGI::escapeHTML(title)
  self.svg = Svg.new(self.input, root: self.root, font_paths: self.font_paths, sys_inputs: sys_inputs)
end

Instance Attribute Details

#htmlObject

Returns the value of attribute html.



146
147
148
# File 'lib/typst.rb', line 146

def html
  @html
end

#svgObject

Returns the value of attribute svg.



145
146
147
# File 'lib/typst.rb', line 145

def svg
  @svg
end

#titleObject

Returns the value of attribute title.



144
145
146
# File 'lib/typst.rb', line 144

def title
  @title
end

Instance Method Details

#markupObject Also known as: document



155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/typst.rb', line 155

def markup
  %{
<!DOCTYPE html>
<html>
<head>
<title>#{title}</title>
</head>
<body>
#{svg.pages.join("<br />")}
</body>
</html>
  }
end