lesspub 1.0.2

CLI tool for downloading Sequences from LessWrong and exporting them as EPUB format ebooks
Documentation
pub fn wrap_html(html: String, title: &str) -> String {
    format!(
        r##"<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
        <meta name="theme-color" content="#000000"/>
        <meta content="ie=edge" http-equiv="x-ua-compatible"/>
        <title>{title}</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    </head>
    <body class="calibre">
{html}
    </body>
</html>"##
    )
}

pub fn wrap_body(body: String, title: &str, url: &str) -> String {
    wrap_html(
        format!(
            r##"
<div class="calibre1">
    <h1><a href="{url}">{title}</a></h1>
{body}
</div>
"##
        ),
        title,
    )
}

pub fn sequence_title_page(title: &str, url: &str, description: Option<String>) -> String {
    let description = description
        .map(|description| {
            format!(
                r##"
    <div class="description">{description}</div>"##
            )
        })
        .unwrap_or_default();
    wrap_html(
        format!(
            r##"
<div class="title-page">
    <h1><a href="{url}">{title}</a></h1>{description}
</div>
"##
        ),
        title,
    )
}

pub fn title_page(title: &str) -> String {
    wrap_html(
        format!(
            r##"
<div class="title-page">
    <h1>{title}</h1>
</div>
"##
        ),
        title,
    )
}

pub fn cover_page(cover_path: &str) -> String {
    wrap_html(
        format!(
            r##"
<div style="text-align: center; padding: 0pt; margin: 0pt;">
    <img src="{cover_path}" alt="cover image" style="width: 100%;"/>
</div>
"##
        ),
        "",
    )
}