///|
pub fn compile(
source : String,
target? : CompileTarget = Text,
line_style?: @backend.LineStyle = @backend.LineStyle::Ascii,
ansi?: Bool = false
) -> Result[String, String] {
let block = @parsing.document.parse(source |> @talc.Input::new)
let blocks = match block {
Ok(blocks) => blocks
Err(e) => return Err(@parsing.format_parse_error(e, source))
}
Ok(
match target {
Html => @backend.render_document(blocks, target=@backend.Mathml)
HtmlText =>
@backend.render_pre(
@backend.render_terminal_document(blocks, line_style~, ansi=false),
)
Text => @backend.render_terminal_document(blocks, line_style~, ansi~)
},
)
}
///|
pub(all) enum CompileTarget {
Text
Html
HtmlText
}