<commit_before>use pulldown_cmark::{html, Options, Parser};

pub fn to_html(markdown: &str, title: &str, description: &str) -> std::string::String {
    let css = r#"
        body {
            max-width: 80ch;
            margin: 0 auto;
            padding: 1rem 1rem 2rem 1rem;
            font-size: 1rem;
            line-height: 1;
        }
        body, code {
            font-family: "Courier New", Courier, monospace;
        }
        code {
            overflow-x: auto;
            display: block;
            background: black;
            color: white;
            padding: 1rem;
        }
        nav a {
            padding: 1ch;
        }
        h1, h2 {
            font-weight: normal;
            font-size: 1rem;
            margin-bottom: 1rem;
        }
        h1 {
            text-transform: uppercase;
            margin-top: 0;
        }
        h2 {
            text-decoration: underline;
            margin-top: 2rem;
        }
        main {
            margin-top: 1rem;
            border-top: 1px dashed black;
            padding-top: 2rem;
            padding-bottom: 2rem;
            border-bottom: 1px dashed black;
            margin-bottom: 3rem;
        }
        header, nav {
            display: flex;
            align-items: center;
            flex-wrap: wrap;
        }
        header::before {
            content: ">";
            margin: 0 1ch 0 0;
        }
        header::after {
            content: "";
            margin: 0 0 0 1ch;
            display: inline-block;
            background: black;
            width: 1ch;
            height: 1em;
            animation: cursor 800ms infinite;
        }
        @keyframes cursor {
            0% {
                opacity: 0;
            }
            50% {
                opacity: 1;
            }
            to {
                opacity: 0;
            }
        }
    "#;

    let parser = Parser::new_ext(markdown, Options::empty());
    let mut html = String::new();
    html::push_html(&mut html, parser);

    format!("
        <!DOCTYPE html>
        <html lang='en-US'>
            <head>
                <title>trevordmiller | {}</title>
                <meta name='description' content='{}'>
                <meta name='author' content='<NAME>'>
                <meta charset='utf-8'>
                <meta name='viewport' content='width=device-width, initial-scale=1'>
                <style type='text/css'>
                    {}
                </style>
                <link rel='alternate' type='application/rss+xml' title='trevordmiller RSS feed' href='/rss.xml'>
            </head>
            <body>
                <header>trevordmiller</header>
                <nav>
                    <a href='/'>posts/</a>
                    <a href='/about/'>about/</a>
                    <a href='/resume/'>resume/</a>
                    <a href='/projects/'>projects/</a>
                </nav>
                <main>
                    {}
                </main>
                <footer>
                    <p>If you would like to get updates when I publish new content, join my email list by sending an email to <u><EMAIL><<EMAIL></u> with a subject of <u>subscribe</u>.</p>
                </footer>
            </body>
        </html>
    ",
        &title,
        &description,
        &css,
        &html
    )
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn it_creates_html_documents() {
        let markdown_file_contents = "- Some list item.";
        let title = "Some title";
        let description = "Some description.";

        let html_document = to_html(&markdown_file_contents, &title, &description);

        assert_eq!(
            html_document.contains("<title>trevordmiller | Some title</title>"),
            true
        );
        assert_eq!(
            html_document.contains("<meta name='description' content='Some description.'>"),
            true
        );
        assert_eq!(
            html_document.contains("font-family: \"Courier New\", Courier, monospace;"),
            true
        );
        assert_eq!(html_document.contains("/rss.xml"), true);
        assert_eq!(html_document.contains("<li>Some list item.</li>"), true);
        assert_eq!(html_document.contains("trevordmiller+subscribe"), true);
    }
}
<commit_msg>Fix contrast problems from audit<commit_after>use pulldown_cmark::{html, Options, Parser};

pub fn to_html(markdown: &str, title: &str, description: &str) -> std::string::String {
    let css = r#"
        body {
            max-width: 80ch;
            margin: 0 auto;
            padding: 1rem 1rem 2rem 1rem;
            font-size: 1rem;
            line-height: 1;
        }
        body, code {
            font-family: "Courier New", Courier, monospace;
        }
        code {
            overflow-x: auto;
            display: block;
            background: whitesmoke;
            padding: 1rem;
        }
        nav a {
            padding: 1ch;
        }
        h1, h2 {
            font-weight: normal;
            font-size: 1rem;
            margin-bottom: 1rem;
        }
        h1 {
            text-transform: uppercase;
            margin-top: 0;
        }
        h2 {
            text-decoration: underline;
            margin-top: 2rem;
        }
        main {
            margin-top: 1rem;
            border-top: 1px dashed black;
            padding-top: 2rem;
            padding-bottom: 2rem;
            border-bottom: 1px dashed black;
            margin-bottom: 3rem;
        }
        header, nav {
            display: flex;
            align-items: center;
            flex-wrap: wrap;
        }
        header::before {
            content: ">";
            margin: 0 1ch 0 0;
        }
        header::after {
            content: "";
            margin: 0 0 0 1ch;
            display: inline-block;
            background: black;
            width: 1ch;
            height: 1em;
            animation: cursor 800ms infinite;
        }
        @keyframes cursor {
            0% {
                opacity: 0;
            }
            50% {
                opacity: 1;
            }
            to {
                opacity: 0;
            }
        }
    "#;

    let parser = Parser::new_ext(markdown, Options::empty());
    let mut html = String::new();
    html::push_html(&mut html, parser);

    format!("
        <!DOCTYPE html>
        <html lang='en-US'>
            <head>
                <title>trevordmiller | {}</title>
                <meta name='description' content='{}'>
                <meta name='author' content='<NAME>'>
                <meta charset='utf-8'>
                <meta name='viewport' content='width=device-width, initial-scale=1'>
                <style type='text/css'>
                    {}
                </style>
                <link rel='alternate' type='application/rss+xml' title='trevordmiller RSS feed' href='/rss.xml'>
            </head>
            <body>
                <header>trevordmiller</header>
                <nav>
                    <a href='/'>posts/</a>
                    <a href='/about/'>about/</a>
                    <a href='/resume/'>resume/</a>
                    <a href='/projects/'>projects/</a>
                </nav>
                <main>
                    {}
                </main>
                <footer>
                    <p>If you would like to get updates when I publish new content, join my email list by sending an email to <u>trevordmiller+subscribe<wbr>@groups.io</u> with a subject of <u>subscribe</u>.</p>
                </footer>
            </body>
        </html>
    ",
        &title,
        &description,
        &css,
        &html
    )
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn it_creates_html_documents() {
        let markdown_file_contents = "- Some list item.";
        let title = "Some title";
        let description = "Some description.";

        let html_document = to_html(&markdown_file_contents, &title, &description);

        assert_eq!(
            html_document.contains("<title>trevordmiller | Some title</title>"),
            true
        );
        assert_eq!(
            html_document.contains("<meta name='description' content='Some description.'>"),
            true
        );
        assert_eq!(
            html_document.contains("font-family: \"Courier New\", Courier, monospace;"),
            true
        );
        assert_eq!(html_document.contains("/rss.xml"), true);
        assert_eq!(html_document.contains("<li>Some list item.</li>"), true);
        assert_eq!(html_document.contains("trevordmiller+subscribe"), true);
    }
}

{'fraction_non_alphanumeric': 0.12481220385993297, 'fraction_numerical': 0.010632150699179475, 'mean_word_length': 1.306503198294243, 'pattern_counts': {'":': 0, '<': 95, '<?xml version=': 0, '>': 98, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7635508', 'n_tokens_mistral': 2529, 'n_tokens_neox': 2379, 'n_words': 554}