///|
pub fn compile(
source : String,
target? : CompileTarget = Text,
line_style? : @backend.LineStyle = @backend.LineStyle::Ascii,
ansi? : Bool = false,
disable_math? : 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, disable_math~)
HtmlText =>
@backend.render_pre(
@backend.render_terminal_document(
blocks,
line_style~,
ansi=false,
disable_math~,
),
)
Text =>
@backend.render_terminal_document(
blocks,
line_style~,
ansi~,
disable_math~,
)
},
)
}
///|
pub(all) enum CompileTarget {
Text
Html
HtmlText
}