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
use cratepush_html;
use ;
use FrontmatterExtractor;
use ;
use Datetime;
/// This function takes a markdown string and returns a tuple of the page attributes
/// and the html output.
///
/// # Arguments
/// * `input` - A markdown string.
/// * `theme` - A string representing the theme to use. See https://docs.rs/syntect/latest/syntect/highlighting/struct.ThemeSet.html#method.load_defaults
/// for a list of available themes.
///
/// # Examples
/// ```
/// use lyt::markdown::parse_markdown;
/// let markdown_input = "\
/// ```toml
/// title = \"This is a fancy **title**\"\n\
/// author = \"pjw\"
/// timestamp = 2023-11-17T00:00:00+00:20
/// ```\n\n\
/// ### Sub-title
/// \n\
/// Hello world, this is a ~~complicated~~ *very simple* example.\n\n\
/// ```rust\n\
/// use std::whatever;\n\
/// \n\
/// fn main() {\n\
/// \tprintln!(\"Hello, world!\");\n\
/// }\n\
/// ```\n\n\
/// This is a [link](https://example.com).\n\n\
/// `this is code`\
/// ";
///
/// let expected_html = "\
/// <h2>Sub-title</h2>\n\
/// <p>Hello world, this is a <del>complicated</del> <em>very simple</em> example.</p>\n\
/// <pre><code class=\"language-rust\"><span style=\"color:#859900;\">use </span><span style=\"color:#839496;\">std::whatever;\n\
/// </span><span style=\"color:#839496;\">\n\
/// </span><span style=\"color:#268bd2;\">fn </span><span style=\"color:#b58900;\">main</span><span style=\"color:#657b83;\">() {\n\
/// </span><span style=\"color:#839496;\">\t</span><span style=\"color:#859900;\">println!</span><span style=\"color:#657b83;\">(</span><span style=\"color:#839496;\">"</span><span style=\"color:#2aa198;\">Hello, world!</span><span style=\"color:#839496;\">"</span><span style=\"color:#657b83;\">)</span><span style=\"color:#839496;\">;\n\
/// </span><span style=\"color:#657b83;\">}\n</span></code></pre>\n\
/// <p>This is a <a href=\"https://example.com\">link</a>.</p>\n\
/// <p><code>this is code</code></p>
/// ";
/// let (attrs, html_output) = parse_markdown(markdown_input, "Solarized (dark)".to_string());
/// assert_eq!(attrs.title, "This is a fancy **title**");
/// assert_eq!(attrs.author, "pjw");
/// assert_eq!(attrs.timestamp.to_string(), "2023-11-17T00:00:00+00:20");
/// assert_eq!(html_output, expected_html);