File: mod.rs

package info (click to toggle)
rust-markdown 0.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 816 kB
  • sloc: makefile: 6
file content (235 lines) | stat: -rw-r--r-- 3,338 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
use std::path::Path;
use std::fs::File;
use std::io::Read;
use markdown;

fn compare(name: &str) {
    let html = format!("tests/fixtures/docs-maruku-unittest/{}.html", name);
    let text = format!("tests/fixtures/docs-maruku-unittest/{}.text", name);
    let mut comp = String::new();
    File::open(Path::new(&html)).unwrap().read_to_string(&mut comp).unwrap();
    let md = Path::new(&text);

    let mut tokens = String::new();
    File::open(md).unwrap().read_to_string(&mut tokens).unwrap();
    println!("{:?}", markdown::tokenize(&tokens));

    assert_diff!(&comp, &markdown::file_to_html(md).unwrap(), " ", 0);
}

fn roundtrip(name: &str) {
    let html = format!("tests/fixtures/docs-maruku-unittest/{}.html", name);
    let text = format!("tests/fixtures/docs-maruku-unittest/{}.text", name);
    let mut comp = String::new();
    File::open(Path::new(&html)).unwrap().read_to_string(&mut comp).unwrap();
    let md = Path::new(&text);

    let mut tokens = String::new();
    File::open(md).unwrap().read_to_string(&mut tokens).unwrap();
    
    let v = markdown::tokenize(&tokens);
    println!("{:?}", v);
    let out = markdown::generate_markdown(v);
    
    println!("BEGIN\n{}\nEND", out);
    
    assert_diff!(&comp, &markdown::to_html(&out), " ", 0);
}

#[test]
pub fn rt_alt() {
    roundtrip("alt")
}

#[test]
pub fn rt_blank() {
    roundtrip("blank")
}


#[test]
pub fn rt_blanks_in_code() {
    roundtrip("blanks_in_code")
}


#[test]
pub fn rt_code() {
    roundtrip("code")
}


#[test]
pub fn rt_code2() {
    roundtrip("code2")
}


#[test]
pub fn rt_code3() {
    roundtrip("code3")
}

#[test]
pub fn rt_easy() {
    roundtrip("easy")
}

#[test]
pub fn rt_headers() {
    roundtrip("headers")
}

//#[test]
//pub fn rt_entities() {
    //roundtrip("entities")
//}

#[test]
pub fn rt_list1() {
    roundtrip("list1")
}

#[test]
pub fn rt_list2() {
    roundtrip("list2")
}

#[test]
pub fn rt_list3() {
    roundtrip("list3")
}

#[test]
pub fn rt_lists() {
    roundtrip("lists")
}

#[test]
pub fn rt_lists8() {
    roundtrip("lists8")
}

#[test]
pub fn rt_one() {
    roundtrip("one")
}

#[test]
pub fn rt_paragraph() {
    roundtrip("paragraph")
}

#[test]
pub fn rt_paragraphs() {
    roundtrip("paragraphs")
}

#[test]
pub fn rt_test() {
    roundtrip("test")
}

#[test]
pub fn rt_wrapping() {
    roundtrip("wrapping")
}



#[test]
pub fn alt() {
    compare("alt")
}


#[test]
pub fn blank() {
    compare("blank")
}

#[test]
pub fn blanks_in_code() {
    compare("blanks_in_code")
}

#[test]
pub fn code() {
    compare("code")
}

#[test]
pub fn code2() {
    compare("code2")
}

#[test]
pub fn code3() {
    compare("code3")
}

#[test]
pub fn easy() {
    compare("easy")
}

#[test]
pub fn headers() {
    compare("headers")
}

//#[test]
//pub fn entities() {
    //compare("entities")
//}

#[test]
pub fn list1() {
    compare("list1")
}

#[test]
pub fn list2() {
    compare("list2")
}

#[test]
pub fn list3() {
    compare("list3")
}

#[test]
pub fn lists() {
    compare("lists")
}

#[test]
pub fn lists8() {
    compare("lists8")
}

#[test]
pub fn one() {
    compare("one")
}

#[test]
pub fn paragraph() {
    compare("paragraph")
}

#[test]
pub fn paragraphs() {
    compare("paragraphs")
}

#[test]
pub fn test() {
    compare("test")
}

#[test]
pub fn wrapping() {
    compare("wrapping")
}