papr-pdf 0.1.0

A fast, keyboard-first CLI tool to compile Markdown, LaTeX, and plain text files into publication-grade PDFs.
//! Typography themes and CSS stylesheets for HTML-based PDF generation.

use crate::cli::Theme;

/// Returns the embedded CSS stylesheet corresponding to the given theme.
pub fn get_theme_css(theme: Theme) -> &'static str {
    match theme {
        Theme::Academic => ACADEMIC_CSS,
        Theme::Github => GITHUB_CSS,
        Theme::Modern => MODERN_CSS,
        Theme::Dark => DARK_CSS,
    }
}

const ACADEMIC_CSS: &str = r#"
@page {
    size: A4;
    margin: 25mm 20mm 25mm 20mm;
    @bottom-right {
        content: counter(page);
    }
}

body {
    font-family: "Latin Modern Roman", "Times New Roman", Times, "Nimbus Roman No9 L", serif;
    font-size: 11pt;
    line-height: 1.6;
    color: #1a1a1a;
    background-color: #ffffff;
    max-width: 100%;
    margin: 0;
    padding: 0;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
    font-family: "Latin Modern Roman", "Times New Roman", Times, serif;
    color: #111111;
    font-weight: bold;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    page-break-after: avoid;
}

h1 { font-size: 20pt; text-align: center; margin-bottom: 1em; }
h2 { font-size: 14pt; border-bottom: 1px solid #ddd; padding-bottom: 4px; }
h3 { font-size: 12pt; }

p {
    margin-top: 0;
    margin-bottom: 0.85em;
    text-align: justify;
    text-justify: inter-word;
}

code {
    font-family: "JetBrains Mono", "Fira Code", "Courier New", monospace;
    font-size: 9.5pt;
    background-color: #f5f5f5;
    padding: 2px 4px;
    border-radius: 3px;
    border: 1px solid #e0e0e0;
}

pre {
    background-color: #f8f9fa;
    border: 1px solid #e1e4e8;
    border-radius: 5px;
    padding: 12px 14px;
    overflow-x: auto;
    page-break-inside: avoid;
    margin-bottom: 1.2em;
}

pre code {
    background-color: transparent;
    padding: 0;
    border: none;
    font-size: 9pt;
    line-height: 1.45;
}

blockquote {
    border-left: 3px solid #0056b3;
    margin: 1.2em 0;
    padding: 4px 16px;
    color: #444;
    background-color: #f7f9fc;
    font-style: italic;
    page-break-inside: avoid;
}

table {
    border-collapse: collapse;
    width: 100%;
    margin: 1.5em 0;
    page-break-inside: avoid;
}

table, th, td {
    border: 1px solid #ccc;
}

th {
    background-color: #f2f2f2;
    font-weight: bold;
    padding: 8px 12px;
    text-align: left;
}

td {
    padding: 7px 12px;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5em auto;
    page-break-inside: avoid;
}

hr {
    border: 0;
    height: 1px;
    background: #ccc;
    margin: 2em 0;
}
"#;

const GITHUB_CSS: &str = r#"
@page {
    size: A4;
    margin: 20mm 18mm 20mm 18mm;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
    font-size: 10.5pt;
    line-height: 1.6;
    color: #24292f;
    background-color: #ffffff;
    max-width: 100%;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    margin-top: 1.4em;
    margin-bottom: 0.5em;
    page-break-after: avoid;
}

h1 { font-size: 18pt; border-bottom: 1px solid #d0d7de; padding-bottom: 0.3em; }
h2 { font-size: 14pt; border-bottom: 1px solid #d0d7de; padding-bottom: 0.3em; }
h3 { font-size: 12pt; }

code {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 85%;
    background-color: rgba(175, 184, 193, 0.2);
    padding: 0.2em 0.4em;
    border-radius: 6px;
}

pre {
    background-color: #f6f8fa;
    border-radius: 6px;
    padding: 14px;
    overflow-x: auto;
    page-break-inside: avoid;
    border: 1px solid #d0d7de;
}

pre code {
    background-color: transparent;
    padding: 0;
}

blockquote {
    border-left: 0.25em solid #d0d7de;
    color: #57609a;
    padding: 0 1em;
    margin: 1em 0;
}

table {
    border-collapse: collapse;
    width: 100%;
    margin: 1.2em 0;
}

th, td {
    padding: 6px 13px;
    border: 1px solid #d0d7de;
}

tr:nth-child(2n) {
    background-color: #f6f8fa;
}

img {
    max-width: 100%;
    height: auto;
}
"#;

const MODERN_CSS: &str = r#"
@page {
    size: A4;
    margin: 22mm 20mm;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 11pt;
    line-height: 1.65;
    color: #1e293b;
    background-color: #ffffff;
}

h1, h2, h3 {
    color: #0f172a;
    letter-spacing: -0.02em;
    page-break-after: avoid;
}

h1 { font-size: 22pt; font-weight: 800; margin-bottom: 0.6em; }
h2 { font-size: 15pt; font-weight: 700; margin-top: 1.5em; }

pre {
    background-color: #0f172a;
    color: #e2e8f0;
    border-radius: 8px;
    padding: 14px 18px;
    page-break-inside: avoid;
}

pre code {
    background-color: transparent;
}

blockquote {
    border-left: 4px solid #3b82f6;
    background-color: #eff6ff;
    border-radius: 4px;
    padding: 8px 16px;
    margin: 1.2em 0;
}

table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    margin: 1.5em 0;
}

th {
    background-color: #f8fafc;
    padding: 10px 14px;
    border-bottom: 1px solid #e2e8f0;
}

td {
    padding: 9px 14px;
    border-bottom: 1px solid #f1f5f9;
}
"#;

const DARK_CSS: &str = r#"
@page {
    size: A4;
    margin: 20mm;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 11pt;
    line-height: 1.6;
    color: #e6edf3;
    background-color: #0d1117;
}

h1, h2, h3, h4 {
    color: #58a6ff;
    page-break-after: avoid;
}

h1 { border-bottom: 1px solid #21262d; padding-bottom: 0.3em; }
h2 { border-bottom: 1px solid #21262d; padding-bottom: 0.3em; }

code {
    background-color: #161b22;
    color: #79c0ff;
    padding: 2px 5px;
    border-radius: 4px;
}

pre {
    background-color: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 14px;
}

pre code {
    background-color: transparent;
    color: inherit;
}

blockquote {
    border-left: 3px solid #388bfd;
    background-color: #161b22;
    padding: 6px 14px;
    color: #8b949e;
}

table, th, td {
    border: 1px solid #30363d;
}

th {
    background-color: #161b22;
}

td {
    background-color: #0d1117;
}
"#;