Pandoc Markdown CSS Theme

repository·master·Indexed 41 days ago

https://github.com/jez/pandoc-markdown-css-theme

A collection of CSS files and Pandoc templates for generating responsive, high-quality standalone HTML files from Markdown. Features include Tufte-style side notes via pandoc-sidenote, KaTeX math rendering, dark mode support, and highly configurable visual styles using CSS variables. Supports advanced code block features like line numbering, highlighting, and tight-code blocks for ASCII art, as well as responsive width utility classes (.wide, .extra-wide, .full-width) and colored note callouts.

Tokens
10.3K
Snippets
43
Records
52
Agent score
52%

What's inside pandoc-markdown-css-theme

  1. Overview of pandoc-markdown-css-theme

    master
    This project provides CSS files and a template for using Pandoc to generate standalone HTML files with a Tufte-inspired aesthetic. It supports most Pandoc Markdown features and adds extras like side notes, colored notes, and specialized image layouts. The design is purely CSS-based and does not require JavaScript, even for side note positioning. The look can be customized using CSS variables.
  2. Overview of pandoc-markdown-css-theme capabilities

    master

    This project provides CSS files and a template designed for use with Pandoc to generate standalone HTML files.

    Key features include:

    • Support for most Pandoc Markdown features and additional extras.
    • Customization via CSS variables.
    • No JavaScript dependency, even for features like side notes.
    • Support for complex elements like math (inline and block), various heading levels, nested lists, checklists, and wide figures.
  3. Features of the Pandoc Markdown CSS Theme

    master

    The theme provides a responsive, CSS-variable-driven design for Pandoc-generated HTML. Key features include:

    • Code Blocks: Supports syntax themes, line numbers, line highlights, and width options (extra wide/full-width).
    • Media: Supports extra wide/full-width images and tables with captions.
    • Notes: Support for side notes and margin notes (using pandoc-sidenote).
    • Navigation: A floating table of contents.
    • Math: $\LaTeX$ math rendering via KaTeX.
    • Dark Mode: Automatically adapts to the user's system color scheme.
    • Responsiveness: Side notes and TOC display inline on small screens and in margins on wide screens.
  4. Create block-based side notes and margin notes

    master

    By default, side notes are inline (only supporting inline elements like bold or links). To include block elements like code blocks or lists, you must use block-based syntax.

    Block-based Syntax

    Prefix the multi-element note with four spaces of indentation (or a tab). Use specific markers in the footnote definition:

    • {^} for a block-based side note.
    • {^-} for a block-based margin note.

    Comparison

    FeatureInline NotesBlock-based Notes
    ContentInline elements onlySupports block elements (code, lists, etc.)
    RenderingImmediately right of anchorNext to the top of the enclosing paragraph
    MobileClickable link to expandUses JavaScript to reorder/collapse

    Note: To include figures with captions in a margin note, use raw HTML <figure> tags directly within the footnote definition.

    Some text which has a block-based side note[^1] and margin note[^2].
    
    [^1]:
        {^} This is a block-based side note. It can contain, e.g. code blocks:
    
        ```ruby
        puts "Hello, world!"
        ```
    
    [^2]:
        {^-} This is a block-based margin note. It can contain, e.g. code blocks:
    
        ```ruby
        puts "Hello, world!"
        ```
  5. Use side notes and margin notes

    master

    The theme transforms standard Markdown footnotes into side notes (margin notes) positioned in the page margin.

    • Side Notes: Standard footnotes [^1] are converted to side notes. They are numbered and aligned with the text.
    • Margin Notes: To create a margin note without a number, use the syntax [^label] followed by {-} in the definition.
    • Footnotes: To force a note to remain a standard bottom-of-page footnote rather than a side note, use the {.} prefix in the definition.

    Note: Side notes and margin notes do not share a namespace. If you mix them, you may end up with two different numbering sequences.

    Markdown footnotes become side notes.[^1]
    
    [^1]: This is a side note.
    
    [^margin]:
      {-} This is a margin note without a number.
    
    [^foot]:
      {.} This is a standard footnote at the bottom of the page.
  6. Use advanced list structures and checklists

    master

    The theme supports standard ordered and unordered lists, as well as advanced list patterns:

    • Checklists: Use [ ] for unchecked and [x] for checked items. Note that visual rendering of checkboxes may vary by browser.
    • Paragraphs in List Items: To include multiple paragraphs within a single list item, separate the text blocks with new lines. This triggers Pandoc to wrap the body text in <p> tags.
    • Tabular Numbers: List numbers are styled using tabular numbers to ensure alignment.
    • Forced Line Breaks: Use \ at the end of a line to force a line break within a list item.
    <!-- Checklist -->
    - [ ] Unchecked item
    - [x] Checked item
    
    <!-- Paragraphs in a list item -->
    - **Bold Title**
    
      This is the first paragraph of the list item body.
    
      This is the second paragraph of the same list item.
    
    <!-- Forced line break in list -->
    - Line starts here\
      Next line follows immediately.
  7. Use margin side notes

    master

    Standard Markdown footnotes ([^1]) are automatically converted into side notes in the margin.

    To create a margin note without a number, use the {-} syntax within the footnote definition.

    Note on behavior:

    • Side notes are positioned in the margin relative to their anchor in the text.
    • If a margin note is longer than the paragraph it is attached to, it may push subsequent notes further down the page.
    • Side notes attached inside blockquotes will have their font-style reset to ensure they do not inherit italics from the blockquote.
    Markdown footnotes become side notes.[^1]
    
    [^1]: This is a standard side note.
    
    [^margin]:
      {-} This is a margin note without a number.
  8. Render LaTeX math with KaTeX

    master

    The theme uses KaTeX to render math. It supports multiple forms of math input (inline and display) provided Pandoc is configured with tex_math_single_backslash. Pandoc will automatically include the necessary CSS and JavaScript files if math is detected in the document.

    $a^2 + b^2 = c^2$ (inline)
    
    $$
    \frac{ - b \pm \sqrt {b^2 - 4ac} }{2a}
    $$
  9. Understand print styles and limitations

    master

    The theme includes custom print styles optimized for U.S. Letter size paper.

    Key behaviors:

    • The layout resembles a narrow desktop screen with a right margin for sidenotes.
    • The Table of Contents is displayed at the top of the page (expanded).
    • Warning: Elements that typically scroll on a screen (like wide tables or math equations) may be clipped when printed. Always test content before publishing.
    • Backgrounds: Code block backgrounds and table header colors will only appear if the user enables "Print backgrounds" in their browser settings.
  10. Use math and wide figures in Pandoc Markdown

    master

    The theme supports inline math using \(...\) and block math using $$...$$. It also provides specialized support for figures that can be styled with different widths using HTML classes within the Markdown file.

    Supported figure width classes:

    • wide: Standard wide figure.
    • extra-wide: Even wider than wide.
    • left-align-caption: Forces the caption to be left-aligned.
    • full-width: Occupies the full width of the container.
    <!-- Inline Math -->
    \(a^2 + b^2 = c^2\)
    
    <!-- Block Math -->
    $$\frac{\Delta \, \Gamma, e : \forall (u :: \kappa). \tau \qquad \Delta \vdash c :: \kappa}{\Delta \, \Gamma \vdash e[c] : [c/u]\tau}$$
    
    <!-- Wide Figure with Caption -->
    <figure class="wide">
      \[\frac{\Delta \, \Gamma, e : \forall (u :: \kappa). \tau \qquad \Delta \vdash c :: \kappa}{\Delta \, \Gamma \vdash e[c] : [c/u]\tau}\]
      <figcaption>Typing rule for $\forall$ types</figcaption>
    </figure>