raw
1use crate::{ast::*, parser::parse_markdown};
2
3#[test]
4fn html_block1() {
5 let doc = parse_markdown("<script>\n</script>").unwrap();
6 assert_eq!(
7 doc,
8 Document {
9 blocks: vec![Block::HtmlBlock("<script>\n</script>".to_owned())]
10 }
11 );
12
13 let doc = parse_markdown("<script>\n\n<h1>hello</h1></script>").unwrap();
14 assert_eq!(
15 doc,
16 Document {
17 blocks: vec![Block::HtmlBlock(
18 "<script>\n\n<h1>hello</h1></script>".to_owned()
19 )]
20 }
21 );
22}
23
24#[test]
25fn html_block2() {
26 let doc = parse_markdown("<!-- \n\nsome commented\n out code -->").unwrap();
27 assert_eq!(
28 doc,
29 Document {
30 blocks: vec![Block::HtmlBlock(
31 "<!-- \n\nsome commented\n out code -->".to_owned()
32 )]
33 }
34 );
35}
36
37#[test]
38fn html_block3() {
39 let doc = parse_markdown(" <? \n\nsome \n code ?> ").unwrap();
40 assert_eq!(
41 doc,
42 Document {
43 blocks: vec![Block::HtmlBlock("<? \n\nsome \n code ?>".to_owned())]
44 }
45 );
46}
47
48#[test]
49fn html_block4() {
50 let doc = parse_markdown(" <!A some \n\n\n text > ").unwrap();
51 assert_eq!(
52 doc,
53 Document {
54 blocks: vec![Block::HtmlBlock("<!A some \n\n\n text >".to_owned())]
55 }
56 );
57}
58
59#[test]
60fn html_block5() {
61 let doc = parse_markdown(" <![CDATA[ ]\n\n[[]]<> ]]> ").unwrap();
62 assert_eq!(
63 doc,
64 Document {
65 blocks: vec![Block::HtmlBlock("<![CDATA[ ]\n\n[[]]<> ]]>".to_owned())]
66 }
67 );
68}
69
70#[test]
71fn html_block6() {
72 let doc = parse_markdown(" <body \n\n").unwrap();
73 assert_eq!(
74 doc,
75 Document {
76 blocks: vec![Block::HtmlBlock("<body \n".to_owned())]
77 }
78 );
79
80 let doc = parse_markdown(" <body a b=c d='e' f=\"g\" >\n</body>\n\n").unwrap();
81 assert_eq!(
82 doc,
83 Document {
84 blocks: vec![Block::HtmlBlock(
85 "<body a b=c d='e' f=\"g\" >\n</body>\n".to_owned()
86 )]
87 }
88 );
89
90 let doc = parse_markdown(" </body> <p>\n</p>\n\n").unwrap();
91 assert_eq!(
92 doc,
93 Document {
94 blocks: vec![Block::HtmlBlock("</body> <p>\n</p>\n".to_owned())]
95 }
96 );
97}
98
99
115
128
146