Markdown parser fork with extended syntax for personal use.
1use markdown::{message, to_html, to_html_with_options, CompileOptions, LineEnding, Options};
2use pretty_assertions::assert_eq;
3
4#[test]
5fn default_line_ending() -> Result<(), message::Message> {
6 assert_eq!(
7 to_html("> a"),
8 "<blockquote>\n<p>a</p>\n</blockquote>",
9 "should use `\\n` default"
10 );
11
12 assert_eq!(
13 to_html("> a\n"),
14 "<blockquote>\n<p>a</p>\n</blockquote>\n",
15 "should infer the first line ending (1)"
16 );
17
18 assert_eq!(
19 to_html("> a\r"),
20 "<blockquote>\r<p>a</p>\r</blockquote>\r",
21 "should infer the first line ending (2)"
22 );
23
24 assert_eq!(
25 to_html("> a\r\n"),
26 "<blockquote>\r\n<p>a</p>\r\n</blockquote>\r\n",
27 "should infer the first line ending (3)"
28 );
29
30 assert_eq!(
31 to_html_with_options(
32 "> a",
33 &Options {
34 compile: CompileOptions {
35 default_line_ending: LineEnding::CarriageReturn,
36 ..Default::default()
37 },
38 ..Default::default()
39 }
40 )?,
41 "<blockquote>\r<p>a</p>\r</blockquote>",
42 "should support the given line ending"
43 );
44
45 assert_eq!(
46 to_html_with_options(
47 "> a\n",
48 &Options {
49 compile: CompileOptions {
50 default_line_ending: LineEnding::CarriageReturn,
51 ..Default::default()
52 },
53 ..Default::default()
54 }
55 )?,
56 // To do: is this a bug in `to_html.js` that it uses `\r` for earlier line endings?
57 // "<blockquote>\r<p>a</p>\r</blockquote>\n",
58 "<blockquote>\n<p>a</p>\n</blockquote>\n",
59 "should support the given line ending, even if line endings exist"
60 );
61
62 Ok(())
63}