#![allow(missing_docs)]
fn convert(html: &str) -> String {
html_to_markdown_rs::convert(html, None)
.unwrap()
.content
.unwrap_or_default()
}
#[test]
fn should_indent_ol_nested_in_ol_to_parent_marker_width() {
let html = "<ol><li>outer<ol><li>inner</li></ol></li></ol>";
let result = convert(html);
assert_eq!(result, "1. outer\n 1. inner\n");
}
#[test]
fn should_indent_ol_nested_in_ul_to_parent_marker_width() {
let html = "<ul><li>outer<ol><li>inner</li></ol></li></ul>";
let result = convert(html);
assert_eq!(result, "- outer\n 1. inner\n");
}
#[test]
fn should_indent_ul_nested_in_ol_to_parent_marker_width() {
let html = "<ol><li>outer<ul><li>inner</li></ul></li></ol>";
let result = convert(html);
assert_eq!(result, "1. outer\n - inner\n");
}
#[test]
fn should_indent_nested_list_to_four_column_marker_when_parent_has_ten_or_more_items() {
let html = "<ol><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li>\
<li>9</li><li>ten<ol><li>inner</li></ol></li></ol>";
let result = convert(html);
assert_eq!(
result,
"1. 1\n2. 2\n3. 3\n4. 4\n5. 5\n6. 6\n7. 7\n8. 8\n9. 9\n10. ten\n 1. inner\n"
);
}
#[test]
fn should_indent_three_levels_deep_by_cumulative_marker_width() {
let html = "<ol><li>l1<ol><li>l2<ol><li>l3</li></ol></li></ol></li></ol>";
let result = convert(html);
assert_eq!(result, "1. l1\n 1. l2\n 1. l3\n");
}
#[test]
fn should_indent_mixed_ul_ol_ul_nesting_by_cumulative_marker_width() {
let html = "<ul><li>a<ol><li>b<ul><li>c</li></ul></li></ol></li></ul>";
let result = convert(html);
assert_eq!(result, "- a\n 1. b\n * c\n");
}
#[test]
fn should_align_continuation_paragraph_to_content_column_inside_nested_ordered_item() {
let html = "<ol><li>outer<ol><li><p>inner</p><p>continuation text</p></li></ol></li></ol>";
let result = convert(html);
assert_eq!(result, "1. outer\n 1. inner\n\n continuation text\n");
}
#[test]
fn should_pad_same_line_continuation_text_by_content_column_inside_nested_ordered_item() {
let html = "<ol><li>outer<ol><li>inner<p>continuation text</p></li></ol></li></ol>";
let result = convert(html);
assert_eq!(result, "1. outer\n 1. inner continuation text\n");
}