#![doc = include_str!("../readme.md")]
pub mod comment;
pub mod conditional_comment;
pub mod mj_accordion;
pub mod mj_accordion_element;
pub mod mj_accordion_text;
pub mod mj_accordion_title;
pub mod mj_attributes;
pub mod mj_attributes_all;
pub mod mj_attributes_class;
pub mod mj_attributes_element;
pub mod mj_body;
pub mod mj_breakpoint;
pub mod mj_button;
pub mod mj_carousel;
pub mod mj_carousel_image;
pub mod mj_column;
pub mod mj_divider;
pub mod mj_font;
pub mod mj_group;
pub mod mj_head;
pub mod mj_hero;
pub mod mj_image;
pub mod mj_include;
pub mod mj_navbar;
pub mod mj_navbar_link;
pub mod mj_preview;
pub mod mj_raw;
pub mod mj_section;
pub mod mj_social;
pub mod mj_social_element;
pub mod mj_spacer;
pub mod mj_style;
pub mod mj_table;
pub mod mj_text;
pub mod mj_title;
pub mod mj_wrapper;
pub mod mjml;
pub mod node;
pub mod prelude;
pub mod text;
#[cfg(feature = "parse")]
mod root;
mod helper;
#[cfg(feature = "parse")]
pub fn parse_with_options<T: AsRef<str>>(
input: T,
opts: &crate::prelude::parser::ParserOptions,
) -> Result<crate::prelude::parser::ParseOutput<mjml::Mjml>, prelude::parser::Error> {
let root = crate::root::Root::parse_with_options(input, opts)?;
Ok(crate::prelude::parser::ParseOutput {
element: root
.element
.into_mjml()
.ok_or(prelude::parser::Error::NoRootNode)?,
warnings: root.warnings,
})
}
#[cfg(all(feature = "parse", feature = "async"))]
pub async fn async_parse_with_options<T: AsRef<str>>(
input: T,
opts: std::sync::Arc<crate::prelude::parser::AsyncParserOptions>,
) -> Result<crate::prelude::parser::ParseOutput<mjml::Mjml>, prelude::parser::Error> {
let root = crate::root::Root::async_parse_with_options(input, opts).await?;
Ok(crate::prelude::parser::ParseOutput {
element: root
.element
.into_mjml()
.ok_or(prelude::parser::Error::NoRootNode)?,
warnings: root.warnings,
})
}
#[cfg(feature = "parse")]
pub fn parse<T: AsRef<str>>(
input: T,
) -> Result<prelude::parser::ParseOutput<mjml::Mjml>, prelude::parser::Error> {
let opts = crate::prelude::parser::ParserOptions::default();
parse_with_options(input, &opts)
}
#[cfg(all(feature = "parse", feature = "async"))]
pub async fn async_parse<T: AsRef<str>>(
input: T,
) -> Result<crate::prelude::parser::ParseOutput<mjml::Mjml>, prelude::parser::Error> {
let opts = std::sync::Arc::new(crate::prelude::parser::AsyncParserOptions::default());
async_parse_with_options(input, opts).await
}
#[cfg(all(test, feature = "parse"))]
mod tests {
#[test]
fn parse_simple() {
let _ = crate::parse("<mjml><mj-head /><mj-body /></mjml>");
}
#[test]
fn parse_with_options() {
let _ =
crate::parse_with_options("<mjml><mj-head /><mj-body /></mjml>", &Default::default());
}
}