Created
July 13, 2025 18:06
-
-
Save ddanielgal/8d348302fd93d05c38cd6f3a3c4b961e to your computer and use it in GitHub Desktop.
Pandoc stylesheet for Kindle-compatible HTML articles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Minimal CSS stylesheet for Pandoc HTML output optimized for Kindle */ | |
| /* Reset and base styles */ | |
| * { | |
| margin: 0; | |
| padding: 0; | |
| box-sizing: border-box; | |
| } | |
| body { | |
| font-family: serif; | |
| line-height: 1.6; | |
| color: #000; | |
| background: #fff; | |
| max-width: 100%; | |
| margin: 0; | |
| padding: 1em; | |
| } | |
| /* Headings */ | |
| h1, h2, h3, h4, h5, h6 { | |
| font-weight: bold; | |
| margin-top: 1.5em; | |
| margin-bottom: 0.5em; | |
| page-break-after: avoid; | |
| } | |
| h1 { font-size: 1.5em; } | |
| h2 { font-size: 1.3em; } | |
| h3 { font-size: 1.1em; } | |
| h4, h5, h6 { font-size: 1em; } | |
| /* Paragraphs */ | |
| p { | |
| margin-bottom: 1em; | |
| text-align: justify; | |
| orphans: 2; | |
| widows: 2; | |
| } | |
| /* Links - simple underline for e-ink */ | |
| a { | |
| color: #000; | |
| text-decoration: underline; | |
| } | |
| /* Emphasis */ | |
| em, i { | |
| font-style: italic; | |
| } | |
| strong, b { | |
| font-weight: bold; | |
| } | |
| /* Code */ | |
| code { | |
| font-family: monospace; | |
| background: none; | |
| border: none; | |
| padding: 0; | |
| font-size: 0.9em; | |
| } | |
| pre { | |
| font-family: monospace; | |
| background: none; | |
| border: none; | |
| padding: 1em 0; | |
| margin: 1em 0; | |
| white-space: pre-wrap; | |
| word-wrap: break-word; | |
| page-break-inside: avoid; | |
| } | |
| pre code { | |
| background: none; | |
| border: none; | |
| padding: 0; | |
| } | |
| /* Lists - keep default styling as requested */ | |
| ul, ol { | |
| margin: 1em 0; | |
| padding-left: 2em; | |
| } | |
| li { | |
| margin-bottom: 0.5em; | |
| } | |
| /* Blockquotes - alternative styling for Kindle */ | |
| blockquote { | |
| margin: 1.5em 0; | |
| padding: 0.5em 1em; | |
| font-style: italic; | |
| background: #f5f5f5; | |
| border: none; | |
| border-left: none; | |
| page-break-inside: avoid; | |
| } | |
| blockquote p { | |
| margin-bottom: 0.5em; | |
| } | |
| blockquote p:last-child { | |
| margin-bottom: 0; | |
| } | |
| /* Alternative blockquote styling - uncomment if background doesn't work well */ | |
| /* | |
| blockquote { | |
| margin: 1.5em 0; | |
| padding: 0; | |
| font-style: italic; | |
| text-indent: 1em; | |
| border: none; | |
| background: none; | |
| } | |
| blockquote:before { | |
| content: """; | |
| font-size: 1.2em; | |
| font-weight: bold; | |
| } | |
| blockquote:after { | |
| content: """; | |
| font-size: 1.2em; | |
| font-weight: bold; | |
| } | |
| */ | |
| /* Tables */ | |
| table { | |
| border-collapse: collapse; | |
| margin: 1em 0; | |
| width: 100%; | |
| page-break-inside: avoid; | |
| } | |
| th, td { | |
| border: 1px solid #000; | |
| padding: 0.5em; | |
| text-align: left; | |
| } | |
| th { | |
| font-weight: bold; | |
| background: #f0f0f0; | |
| } | |
| /* Images */ | |
| img { | |
| max-width: 100%; | |
| height: auto; | |
| display: block; | |
| margin: 1em auto; | |
| page-break-inside: avoid; | |
| } | |
| /* Horizontal rules */ | |
| hr { | |
| border: none; | |
| border-top: 1px solid #000; | |
| margin: 2em 0; | |
| page-break-after: avoid; | |
| } | |
| /* Remove default margins from first and last elements */ | |
| *:first-child { | |
| margin-top: 0; | |
| } | |
| *:last-child { | |
| margin-bottom: 0; | |
| } | |
| /* Page break helpers */ | |
| .page-break { | |
| page-break-before: always; | |
| } | |
| /* Kindle-specific optimizations */ | |
| @media screen and (max-device-width: 758px) { | |
| body { | |
| padding: 0.5em; | |
| } | |
| h1, h2, h3, h4, h5, h6 { | |
| margin-top: 1em; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment