module Crst
Defined in:
crst.crcrst/base_renderer.cr
crst/config.cr
crst/errors.cr
crst/escaper.cr
crst/html_renderer.cr
crst/inline_parser.cr
crst/latex_renderer.cr
crst/line_reader.cr
crst/nodes.cr
crst/parser.cr
crst/text_renderer.cr
crst/xml_renderer.cr
Constant Summary
-
VERSION =
"1.0.8" -
Current version of the crst library
Class Method Summary
-
.parse(input : String, config : Config = Config.new) : Document
Parses RST text and returns the AST document structure
-
.to_html(input : String, config : Config = Config.new) : String
Converts RST text directly to HTML
-
.to_latex(input : String, config : Config = Config.new) : String
Converts RST text to LaTeX format
-
.to_text(input : String, config : Config = Config.new) : String
Converts RST text to plain text
-
.to_xml(input : String, config : Config = Config.new) : String
Converts RST text to XML format
Class Method Detail
Parses RST text and returns the AST document structure
This is the main entry point for parsing RST content. It returns
a Document node containing the complete AST that can be traversed
or rendered to various output formats.
input - The RST text to parse config - Optional configuration for parsing behavior
Returns a Document containing all parsed nodes
Example:
doc = Crst.parse("Hello **World**")
doc.children.size # => 1
Converts RST text directly to HTML
This is a convenience method that combines parsing and rendering
in a single step. For more control over the rendering process,
use .parse followed by HTMLRenderer.
input - The RST text to convert config - Optional configuration for parsing and rendering
Returns the HTML string representation
Example:
html = Crst.to_html("**Bold** text")
html # => "<p><strong>Bold</strong> text</p>\n"
Converts RST text to LaTeX format
input - The RST text to convert config - Optional configuration for parsing and rendering
Returns the LaTeX string representation
Example:
latex = Crst.to_latex("Section\n=======")
latex.includes?("\\section") # => true
Converts RST text to plain text
Strips all markup and returns the text content only. Useful for generating summaries or search indexes.
input - The RST text to convert config - Optional configuration for parsing and rendering
Returns the plain text string
Example:
text = Crst.to_text("**Bold** text")
text # => "Bold text"
Converts RST text to XML format
The XML output represents the AST structure in a machine-readable format that preserves all document semantics.
input - The RST text to convert config - Optional configuration for parsing and rendering
Returns the XML string representation
Example:
xml = Crst.to_xml("Paragraph")
xml.includes?("<paragraph>") # => true