markdown2 :: LatexRenderer :: document_class=
LaTeX document classmarkdown2 :: LatexRenderer :: escaped_chars
LaTeX characters to escapemarkdown2 :: LatexRenderer :: escaped_chars=
LaTeX characters to escapemarkdown2 :: LatexRenderer :: latex_escape
Escapestring
to LaTeX
markdown2 :: LatexRenderer :: page_format=
LaTeX document page formatmarkdown2 :: LatexRenderer :: use_listings
Uselistings
package for code blocks?
markdown2 :: LatexRenderer :: use_listings=
Uselistings
package for code blocks?
markdown2 :: LatexRenderer :: wrap_document
Generate the LaTeX document wrappermarkdown2 :: LatexRenderer :: wrap_document=
Generate the LaTeX document wrappermarkdown2 $ LatexRenderer :: SELF
Type of this instance, automatically specialized in every classcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
markdown2 :: MdVisitor :: defaultinit
markdown2 :: MdRenderer :: defaultinit
core :: Object :: defaultinit
markdown2 :: LatexRenderer :: document_class=
LaTeX document classmarkdown2 :: LatexRenderer :: escaped_chars
LaTeX characters to escapemarkdown2 :: LatexRenderer :: escaped_chars=
LaTeX characters to escapecore :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
markdown2 :: LatexRenderer :: latex_escape
Escapestring
to LaTeX
core :: Object :: output_class_name
Display class name on stdout (debug only).markdown2 :: LatexRenderer :: page_format=
LaTeX document page formatmarkdown2 :: LatexRenderer :: use_listings
Uselistings
package for code blocks?
markdown2 :: LatexRenderer :: use_listings=
Uselistings
package for code blocks?
markdown2 :: LatexRenderer :: wrap_document
Generate the LaTeX document wrappermarkdown2 :: LatexRenderer :: wrap_document=
Generate the LaTeX document wrapper
# Markdown document renderer to LaTeX
class LatexRenderer
super MdRenderer
# Generate the LaTeX document wrapper
#
# The header includes:
# * document class
# * package importation
# * begin and end document directives
var wrap_document = false is optional, writable
# LaTeX document class
#
# Default is `article`.
var document_class = "article" is optional, writable
# LaTeX document page format
#
# Default is `letter`.
var page_format = "letter" is optional, writable
# LaTeX font size
#
# Default is `10pt`.
var font_size = "10pt" is optional, writable
# Use `listings` package for code blocks?
var use_listings = false is optional, writable
# LaTeX output under construction
private var latex: Buffer is noinit
# Render `document` as LaTeX
redef fun render(document) do
latex = new Buffer
enter_visit(document)
return latex.write_to_string
end
redef fun visit(node) do node.render_latex(self)
# Indentation level
var indent = 0
# Add a raw `string` to the output
#
# Raw means that the string will not be escaped.
fun add_raw(string: String) do latex.append string
# Add `text` string to the output
#
# The string will be escaped.
fun add_text(text: String) do latex.append latex_escape(text)
# Add a blank line to the output
fun add_line do
if not latex.is_empty and latex.last != '\n' then
latex.add '\n'
end
end
# Add an indentation depending on `ident` level
fun add_indent do latex.append " " * indent
# Escape `string` to LaTeX
fun latex_escape(string: String): String do
var buffer = new Buffer
for i in [0 .. string.length[ do
var c = string.chars[i]
if c == '>' then
buffer.append "\\textgreater"
continue
else if c == '<' then
buffer.append "\\textless"
continue
else if c == '\\' then
buffer.append "\\textbackslash"
continue
else if escaped_chars.has(c) then
buffer.add '\\'
end
buffer.add c
end
return buffer.to_s
end
# LaTeX characters to escape
var escaped_chars = ['%', '$', '{', '}', '_', '#', '&']
end
lib/markdown2/markdown_latex_rendering.nit:22,1--111,3