A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.rs/markdown/latest/markdown/fn.to_html_with_options.html below:

to_html_with_options in markdown - Rust

Function to_html_with_optionsSource
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 markdown::{to_html_with_options, CompileOptions, Options};

let result = to_html_with_options("~Venus~Mars!", &Options::gfm())?;

assert_eq!(result, "<p><del>Venus</del>Mars!</p>");

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>");

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4