pub fn to_html_with_options(
value: &str,
options: &Options,
) -> Result<String, Message>Expand description
Turn markdown into HTML, with configuration.
§Errors
to_html_with_options() never errors with normal markdown because markdown
does not have syntax errors, so feel free to unwrap().
However, MDX does have syntax errors.
When MDX is turned on, there are several errors that can occur with how
expressions, ESM, and JSX are written.
§Examples
use socketry_markdown::{to_html_with_options, CompileOptions, Options};
// Use GFM:
let result = to_html_with_options("~Venus~Mars!", &Options::gfm())?;
assert_eq!(result, "<p><del>Venus</del>Mars!</p>");
// Live dangerously / trust the author:
let result = to_html_with_options("<div>\n\n# Hi Jupiter!\n\n</div>", &Options {
compile: CompileOptions {
allow_dangerous_html: true,
allow_dangerous_protocol: true,
..CompileOptions::default()
},
..Options::default()
})?;
assert_eq!(result, "<div>\n<h1>Hi Jupiter!</h1>\n</div>");