1#![no_std]
14#![deny(clippy::pedantic)]
15#![allow(clippy::doc_link_with_quotes)]
16#![allow(clippy::missing_panics_doc)]
17#![allow(clippy::must_use_candidate)]
18#![allow(clippy::too_many_lines)]
19#![allow(clippy::result_large_err)]
20#![doc(
21 html_logo_url = "https://raw.githubusercontent.com/wooorm/markdown-rs/8924580/media/logo-monochromatic.svg?sanitize=true"
22)]
23
24extern crate alloc;
25mod align_kind;
26mod block_parser;
27mod byte_scan;
28mod code_fence;
29mod configuration;
30mod definitions;
31mod document;
32mod event_html_renderer;
33mod event_parser;
34mod headings;
35mod inline_parser;
36pub mod markdown;
37mod node_syntax;
38mod reference_kind;
39pub mod stream;
40mod util;
41mod value_builder;
42
43pub mod message; #[doc(hidden)]
46pub use util::sanitize_uri::sanitize;
47
48pub use util::line_ending::LineEnding;
49
50pub use align_kind::AlignKind;
51pub use code_fence::CodeFence;
52pub use configuration::{CompileOptions, Constructs, Options, ParseOptions};
53pub use document::{
54 AstBuilder, BuildProgress, Children, Descendants, Document, DocumentEvents,
55 Node as DocumentNode, NodeId,
56};
57pub use event_html_renderer::{render_events, EventHtmlRenderer};
58pub use event_parser::EventParser;
59pub use headings::{HeadingEntry, HeadingOptions};
60pub use markdown::to_markdown_node;
61pub use markdown::{to_markdown, to_markdown_with_options};
62pub use markdown::{IndentOptions, LineWrapping, Options as MarkdownOptions};
63pub use node_syntax::NodeSyntax;
64pub use reference_kind::ReferenceKind;
65
66use alloc::string::String;
67
68pub fn to_html(value: &str) -> String {
82 to_html_with_options(value, &Options::default())
83}
84
85pub fn to_html_with_options(value: &str, options: &Options) -> String {
112 let mut output = String::with_capacity(value.len().min(4096));
114 let result = EventHtmlRenderer::new(value, &options.compile, &mut output)
115 .render_markdown(&options.parse);
116 match result {
117 Ok(()) => output,
118 Err(_) => unreachable!(
119 "parser events are balanced and source-valid; writing to String cannot fail"
120 ),
121 }
122}