File: quotes.rs

package info (click to toggle)
rust-html2md 0.2.15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 484 kB
  • sloc: makefile: 2
file content (51 lines) | stat: -rw-r--r-- 1,340 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
extern crate html2md;

use html2md::parse_html;
use pretty_assertions::assert_eq;
use indoc::indoc;

#[test]
fn test_quotes() {
    let md = parse_html("<p><blockquote>here's a quote\n next line of it</blockquote>And some text after it</p>");
    assert_eq!(md, "\
> here's a quote next line of it

And some text after it")
}

#[test]
fn test_quotes2() {
    let md = parse_html("<p><blockquote>here's<blockquote>nested quote!</blockquote> a quote\n next line of it</blockquote></p>");
    assert_eq!(md, "\
> here's
> > nested quote!
>
>  a quote next line of it")
}

#[test]
fn test_blockquotes() {
    let md = parse_html("<blockquote>Quote at the start of the message</blockquote>Should not crash the parser");
    assert_eq!(md, "\
> Quote at the start of the message

Should not crash the parser")
}

#[test]
fn test_details() {
    let html = indoc! {"
    <details>
        <summary>There are more things in heaven and Earth, <b>Horatio</b></summary>
        <p>Than are dreamt of in your philosophy</p>
    </details>
    "};
    let md = parse_html(&html);
    assert_eq!(md, "<details> <summary>There are more things in heaven and Earth, **Horatio**</summary>\n\nThan are dreamt of in your philosophy\n\n</details>")
}

#[test]
fn test_subsup() {
    let md = parse_html("X<sub>2</sub>");
    assert_eq!(md, r#"X<sub>2</sub>"#)
}