use pter::convert; #[test] fn simple_email() { let html = r#"
Hi Max,
Just confirming our meeting tomorrow at 2pm.
Best,
Alice
Please review the document.
Direct link: https://example.com
"#; let md = convert(html); assert!(md.contains("[document](https://example.com/doc)")); // Link text matches URL — no markdown link syntax assert!(md.contains("Direct link: https://example.com")); } #[test] fn email_with_tracking_pixels() { let html = r#"Content here
"#;
let md = convert(html);
assert!(md.contains("Content here"));
assert!(!md.contains("tracker"));
assert!(!md.contains("data:image"));
assert!(md.contains(""));
}
#[test]
fn email_with_quoted_reply() {
let html = r#"
Thanks, that works for me.
"#; let md = convert(html); assert!(md.contains("Thanks, that works for me.")); assert!(md.contains("> Can we meet at 3pm instead?")); } #[test] fn email_with_signature_line() { let html = r#"Can we meet at 3pm instead?
See you then.
Alice Smith
Engineering Lead
"#; let md = convert(html); assert!(md.contains("See you then.")); assert!(md.contains("---")); assert!(md.contains("Alice Smith")); } #[test] fn deeply_nested_blockquotes() { let html = r#"Got it.
"#; let md = convert(html); assert!(md.contains("Got it.")); assert!(md.contains("> Sounds good.")); assert!(md.contains("> > Can we reschedule?")); assert!(md.contains("> > > Original message here.")); } #[test] fn complex_list_structure() { let html = r#"Sounds good.
Can we reschedule?
Original message here.
Action items:
Here's the code:
fn main() {
println!("hello");
}
"#;
let md = convert(html);
assert!(md.contains("Here's the code:"));
assert!(md.contains("```\nfn main()"));
assert!(md.contains(" println!"));
}
#[test]
fn hidden_content_stripped() {
let html = r#"
Visible content
More visible
"#; let md = convert(html); assert!(md.contains("Visible content")); assert!(!md.contains("should not appear")); assert!(!md.contains("Also hidden")); assert!(md.contains("More visible")); } #[test] fn script_and_style_fully_removed() { let html = r#"Safe content
"#; let md = convert(html); assert_eq!(md, "Safe content"); } #[test] fn newsletter_table_layout() { // Typical email newsletter wrapped in layout tables let html = r#"
|
Order summary:
| Item | Qty | Price |
|---|---|---|
| Widget | 3 | $15.00 |
| Gadget | 1 | $29.99 |
Real content
More content
"#; let md = convert(html); assert!(md.contains("Real content")); assert!(md.contains("More content")); assert!(!md.contains("invisible")); assert!(!md.contains("pixel.gif")); } // -- Reply chain tests -- #[test] fn gmail_reply_chain() { let html = r#"Thanks, that works for me.
Can we meet at 3pm instead of 2pm?
Hey, are we still on for lunch?
I'll handle it.
From: Alice Smith
Sent: Monday, January 5, 2026
To: Bob Jones
Subject: Action needed
Can you take a look at the report?
Got it, thanks!
Here's the update.
On Mon, Jan 5, Alice wrote:What's the status?
FYI, see below.
From: Alice
The deadline has been moved to Friday.
"#; let md = convert(html); assert!(md.contains("Will do, thanks.")); assert!(md.contains("> ")); assert!(md.contains("send me the files")); } #[test] fn attribution_preserved_above_quote() { let html = r#"Please send me the files by EOD.
Agreed.
Let's go with option B.