use std::sync::LazyLock;
pub mod html;
pub mod plugins;
pub mod rules;
#[cfg(feature = "fetch")]
pub mod fetch;
pub(crate) mod converter;
pub(crate) mod options;
mod context;
mod dom;
mod escape;
mod whitespace;
pub use context::Context;
pub use converter::{Action, Converter, ConverterBuilder, Plugin, Rule};
pub use options::{
BulletMarker, CodeBlockStyle, EmDelimiter, EscapeMode, Fence, HeadingStyle, HorizontalRule,
LinkReferenceStyle, LinkStyle, Options, StrongDelimiter,
};
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error(transparent)]
Io(#[from] std::io::Error),
}
pub type Result<T> = std::result::Result<T, Error>;
#[must_use]
pub fn convert(html: &str) -> String {
static CONVERTER: LazyLock<Converter> =
LazyLock::new(|| Converter::builder().use_plugin(rules::CommonMark).build());
CONVERTER.convert(html)
}
#[must_use]
pub fn convert_gfm(html: &str) -> String {
static CONVERTER: LazyLock<Converter> = LazyLock::new(|| {
Converter::builder()
.use_plugin(rules::CommonMark)
.use_plugin(plugins::Gfm)
.build()
});
CONVERTER.convert(html)
}