mod html_to_markdown;
mod markdown;
mod node;
pub use markdown::{Markdown, to_html};
pub use node::{
Blockquote, Break, Code, CodeInline, ColorTheme, Definition, Delete, Emphasis, Footnote, FootnoteRef, Fragment,
Heading, HorizontalRule, Html, Image, ImageRef, Link, LinkRef, List, ListStyle, Math, MathInline,
MdxFlowExpression, MdxJsEsm, MdxJsxFlowElement, MdxJsxTextElement, MdxTextExpression, Node, Point, Position,
RenderOptions, Strong, TableAlign, TableAlignKind, TableCell, TableRow, Text, Title, TitleSurroundStyle, Toml, Url,
UrlSurroundStyle, Yaml, attr_value::AttrValue,
};
#[cfg(feature = "html-to-markdown")]
pub use html_to_markdown::{ConversionOptions, convert_html_to_markdown};
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_to_html() {
let markdown = "# Hello, world!";
let html = to_html(markdown);
assert_eq!(html, "<h1>Hello, world!</h1>");
}
#[cfg(feature = "html-to-markdown")]
#[test]
fn test_html_to_markdown_simple_paragraph() {
let html = "<p>Hello world</p>";
match convert_html_to_markdown(html, ConversionOptions::default()) {
Ok(markdown) => assert_eq!(markdown.trim(), "Hello world"),
Err(e) => panic!("HTML to Markdown conversion failed: {:?}", e),
}
}
#[cfg(feature = "html-to-markdown")]
#[test]
fn test_html_to_markdown_empty_input() {
let html = "";
match convert_html_to_markdown(html, ConversionOptions::default()) {
Ok(markdown) => assert_eq!(markdown, ""),
Err(e) => panic!("HTML to Markdown conversion failed for empty input: {:?}", e),
}
}
#[cfg(feature = "html-to-markdown")]
#[test]
fn test_html_to_markdown_div_element() {
let html = "<div>Content in div</div>";
let result = convert_html_to_markdown(html, ConversionOptions::default());
assert!(result.is_ok());
let markdown = result.unwrap();
assert_eq!(markdown.trim(), "Content in div");
}
}