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.



120
121
122
123
124
125
# File 'lib/typst.rb', line 120

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.



118
119
120
# File 'lib/typst.rb', line 118

def html
  @html
end

#svgObject

Returns the value of attribute svg.



117
118
119
# File 'lib/typst.rb', line 117

def svg
  @svg
end

#titleObject

Returns the value of attribute title.



116
117
118
# File 'lib/typst.rb', line 116

def title
  @title
end

Instance Method Details

#markupObject Also known as: document



127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/typst.rb', line 127

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