#![deny(clippy::undocumented_unsafe_blocks)]
pub mod ast;
mod block;
mod entities;
mod html;
mod inline;
mod renderers;
#[cfg(feature = "ansi")]
mod ansi;
#[cfg(feature = "html-parser")]
mod html_parser;
#[cfg(feature = "html")]
mod render;
pub mod ffi;
pub use ast::{Block, ListKind, TableAlignment, TableData};
pub use block::parse_to_ast;
pub use renderers::markdown::render_markdown;
#[cfg(feature = "ansi")]
pub use ansi::{AnsiOptions, render_ansi};
#[cfg(feature = "html")]
#[doc(hidden)]
pub use block::benchmark_parse_table_row as __benchmark_parse_table_row;
#[cfg(feature = "html")]
pub use block::parse;
#[cfg(feature = "html-parser")]
pub use html_parser::{
HtmlParseOptions, UnknownInlineHandling, html_to_markdown, parse_html_to_ast,
};
#[cfg(feature = "html")]
#[doc(hidden)]
pub use inline::benchmark_parse_inline as __benchmark_parse_inline;
#[cfg(feature = "html")]
#[doc(hidden)]
pub use render::benchmark_heading_slug as __benchmark_heading_slug;
#[inline(always)]
pub(crate) fn is_ascii_punctuation(b: u8) -> bool {
matches!(b, b'!'..=b'/' | b':'..=b'@' | b'['..=b'`' | b'{'..=b'~')
}
#[inline(always)]
pub(crate) fn utf8_char_len(first: u8) -> usize {
if first < 0x80 {
1
} else if first < 0xE0 {
2
} else if first < 0xF0 {
3
} else {
4
}
}
pub struct ParseOptions {
pub hard_breaks: bool,
pub enable_highlight: bool,
pub enable_strikethrough: bool,
pub enable_underline: bool,
pub enable_tables: bool,
pub enable_autolink: bool,
pub enable_task_lists: bool,
pub disable_raw_html: bool,
pub max_nesting_depth: usize,
pub max_input_size: usize,
pub enable_heading_ids: bool,
pub enable_heading_anchors: bool,
pub enable_indented_code_blocks: bool,
pub no_html_blocks: bool,
pub no_html_spans: bool,
pub tag_filter: bool,
pub collapse_whitespace: bool,
pub permissive_atx_headers: bool,
pub enable_wiki_links: bool,
pub enable_latex_math: bool,
}
impl Default for ParseOptions {
fn default() -> Self {
Self {
hard_breaks: true,
enable_highlight: true,
enable_strikethrough: true,
enable_underline: true,
enable_tables: true,
enable_autolink: true,
enable_task_lists: true,
disable_raw_html: false,
max_nesting_depth: 128,
max_input_size: 0,
enable_heading_ids: false,
enable_heading_anchors: false,
enable_indented_code_blocks: true,
no_html_blocks: false,
no_html_spans: false,
tag_filter: false,
collapse_whitespace: false,
permissive_atx_headers: false,
enable_wiki_links: false,
enable_latex_math: false,
}
}
}