extern crate pulldown_cmark;
include!("normalize_html.rs.inc");
#[test]
fn gfm_table_test_1() {
let original = r##"| foo | bar |
| --- | --- |
| baz | bim |
"##;
let expected = r##"<table>
<thead>
<tr>
<th>foo</th>
<th>bar</th>
</tr>
</thead>
<tbody>
<tr>
<td>baz</td>
<td>bim</td>
</tr>
</tbody>
</table>
"##;
use pulldown_cmark::{Parser, html, Options};
let mut s = String::new();
let mut opts = Options::empty();
opts.insert(Options::ENABLE_TABLES);
opts.insert(Options::ENABLE_FOOTNOTES);
opts.insert(Options::ENABLE_STRIKETHROUGH);
opts.insert(Options::ENABLE_TASKLISTS);
let p = Parser::new_ext(&original, opts);
html::push_html(&mut s, p);
assert_eq!(normalize_html(&expected), normalize_html(&s));
}
#[test]
fn gfm_table_test_2() {
let original = r##"| abc | defghi |
:-: | -----------:
bar | baz
"##;
let expected = r##"<table>
<thead>
<tr>
<th align="center">abc</th>
<th align="right">defghi</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">bar</td>
<td align="right">baz</td>
</tr>
</tbody>
</table>
"##;
use pulldown_cmark::{Parser, html, Options};
let mut s = String::new();
let mut opts = Options::empty();
opts.insert(Options::ENABLE_TABLES);
opts.insert(Options::ENABLE_FOOTNOTES);
opts.insert(Options::ENABLE_STRIKETHROUGH);
opts.insert(Options::ENABLE_TASKLISTS);
let p = Parser::new_ext(&original, opts);
html::push_html(&mut s, p);
assert_eq!(normalize_html(&expected), normalize_html(&s));
}
#[test]
fn gfm_table_test_3() {
let original = r##"| f\|oo |
| ------ |
| b `\|` az |
| b **\|** im |
"##;
let expected = r##"<table>
<thead>
<tr>
<th>f|oo</th>
</tr>
</thead>
<tbody>
<tr>
<td>b <code>|</code> az</td>
</tr>
<tr>
<td>b <strong>|</strong> im</td>
</tr>
</tbody>
</table>
"##;
use pulldown_cmark::{Parser, html, Options};
let mut s = String::new();
let mut opts = Options::empty();
opts.insert(Options::ENABLE_TABLES);
opts.insert(Options::ENABLE_FOOTNOTES);
opts.insert(Options::ENABLE_STRIKETHROUGH);
opts.insert(Options::ENABLE_TASKLISTS);
let p = Parser::new_ext(&original, opts);
html::push_html(&mut s, p);
assert_eq!(normalize_html(&expected), normalize_html(&s));
}
#[test]
fn gfm_table_test_4() {
let original = r##"| abc | def |
| --- | --- |
| bar | baz |
> bar
"##;
let expected = r##"<table>
<thead>
<tr>
<th>abc</th>
<th>def</th>
</tr>
</thead>
<tbody>
<tr>
<td>bar</td>
<td>baz</td>
</tr>
</tbody>
</table>
<blockquote>
<p>bar</p>
</blockquote>
"##;
use pulldown_cmark::{Parser, html, Options};
let mut s = String::new();
let mut opts = Options::empty();
opts.insert(Options::ENABLE_TABLES);
opts.insert(Options::ENABLE_FOOTNOTES);
opts.insert(Options::ENABLE_STRIKETHROUGH);
opts.insert(Options::ENABLE_TASKLISTS);
let p = Parser::new_ext(&original, opts);
html::push_html(&mut s, p);
assert_eq!(normalize_html(&expected), normalize_html(&s));
}
#[test]
fn gfm_table_test_5() {
let original = r##"| abc | def |
| --- | --- |
| bar | baz |
bar
bar
"##;
let expected = r##"<table>
<thead>
<tr>
<th>abc</th>
<th>def</th>
</tr>
</thead>
<tbody>
<tr>
<td>bar</td>
<td>baz</td>
</tr>
<tr>
<td>bar</td>
<td></td>
</tr>
</tbody>
</table>
<p>bar</p>
"##;
use pulldown_cmark::{Parser, html, Options};
let mut s = String::new();
let mut opts = Options::empty();
opts.insert(Options::ENABLE_TABLES);
opts.insert(Options::ENABLE_FOOTNOTES);
opts.insert(Options::ENABLE_STRIKETHROUGH);
opts.insert(Options::ENABLE_TASKLISTS);
let p = Parser::new_ext(&original, opts);
html::push_html(&mut s, p);
assert_eq!(normalize_html(&expected), normalize_html(&s));
}
#[test]
fn gfm_table_test_6() {
let original = r##"| abc | def |
| --- |
| bar |
"##;
let expected = r##"<p>| abc | def |
| --- |
| bar |</p>
"##;
use pulldown_cmark::{Parser, html, Options};
let mut s = String::new();
let mut opts = Options::empty();
opts.insert(Options::ENABLE_TABLES);
opts.insert(Options::ENABLE_FOOTNOTES);
opts.insert(Options::ENABLE_STRIKETHROUGH);
opts.insert(Options::ENABLE_TASKLISTS);
let p = Parser::new_ext(&original, opts);
html::push_html(&mut s, p);
assert_eq!(normalize_html(&expected), normalize_html(&s));
}
#[test]
fn gfm_table_test_7() {
let original = r##"| abc | def |
| --- | --- |
| bar |
| bar | baz | boo |
"##;
let expected = r##"<table>
<thead>
<tr>
<th>abc</th>
<th>def</th>
</tr>
</thead>
<tbody>
<tr>
<td>bar</td>
<td></td>
</tr>
<tr>
<td>bar</td>
<td>baz</td>
</tr>
</tbody>
</table>
"##;
use pulldown_cmark::{Parser, html, Options};
let mut s = String::new();
let mut opts = Options::empty();
opts.insert(Options::ENABLE_TABLES);
opts.insert(Options::ENABLE_FOOTNOTES);
opts.insert(Options::ENABLE_STRIKETHROUGH);
opts.insert(Options::ENABLE_TASKLISTS);
let p = Parser::new_ext(&original, opts);
html::push_html(&mut s, p);
assert_eq!(normalize_html(&expected), normalize_html(&s));
}
#[test]
fn gfm_table_test_8() {
let original = r##"| abc | def |
| --- | --- |
"##;
let expected = r##"<table>
<thead>
<tr>
<th>abc</th>
<th>def</th>
</tr>
</thead>
</table>
"##;
use pulldown_cmark::{Parser, html, Options};
let mut s = String::new();
let mut opts = Options::empty();
opts.insert(Options::ENABLE_TABLES);
opts.insert(Options::ENABLE_FOOTNOTES);
opts.insert(Options::ENABLE_STRIKETHROUGH);
opts.insert(Options::ENABLE_TASKLISTS);
let p = Parser::new_ext(&original, opts);
html::push_html(&mut s, p);
assert_eq!(normalize_html(&expected), normalize_html(&s));
}