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

Instance Method Summary collapse

Methods inherited from Base

from_s, from_zip, #write

Constructor Details

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

Returns a new instance of Html.



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

def initialize(input, title: nil, root: ".", font_paths: [])
  super(input, root: root, font_paths: font_paths)
  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)
end

Instance Attribute Details

#htmlObject

Returns the value of attribute html.



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

def html
  @html
end

#svgObject

Returns the value of attribute svg.



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

def svg
  @svg
end

#titleObject

Returns the value of attribute title.



142
143
144
# File 'lib/typst.rb', line 142

def title
  @title
end

Instance Method Details

#markupObject Also known as: document



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

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