Skip to content

Support custom CSS styling and HTML output #30

Description

@135yshr

Background

Requested via Zenn comment: https://zenn.dev/link/comments/18e8c67d0561bd

カスタムcssでの修飾機能があるといいなと思いました(そのためにはHTML出力もあると便利?)

Proposal

Two related capabilities:

1. Custom CSS injection

Add a -css <path> flag (or -css <path>... to allow multiple) that injects user CSS after the built-in GitHub-flavored stylesheet so users can override or extend it.

md2pdf -css custom.css document.md

Use cases: corporate branding (logo colors, fonts), client-specific deliverable formatting, presentation-mode tweaks.

2. HTML output mode

Add a -html flag (or -format html) that stops the pipeline at step 3 (Build HTML) and emits the self-contained HTML instead of running Playwright.

md2pdf -html document.md   # produces document.html

Benefits:

  • Lets users iterate on custom CSS quickly in a browser without spinning up Chromium each time.
  • Useful for users who only want HTML (e.g. publishing to a static site).
  • Removes the Playwright dependency for HTML-only workflows.

Design considerations

  • Both flags should be composable: -html -css custom.css should produce HTML with the custom CSS applied.
  • Custom CSS should be embedded inline in the <style> tag (not linked) to keep the HTML self-contained, matching md2pdf's current philosophy.
  • Document precedence clearly: built-in CSS → custom CSS (latter wins).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions