Skip to main content

Markdown から美しい日本語文書 (HTML/PDF) を作る — 日本語組版CSS・CJKフレンドリー・Chrome印刷

Project description

washi-md

日本語 | English | 繁體中文 | 한국어

Markdown から美しい日本語文書 (HTML / PDF) を作るコマンド。 横書きのビジネス文書から、縦書きの小説、原稿用紙まで、 コマンド一つで日本語らしく組む。

pip install washi-md

washi report.md          # → report.html (組版済み・自己完結・1ファイル)
washi report.md --pdf    # → report.pdf も出力 (Chrome/Chromium ヘッドレス印刷)

なにが「綺麗」になるか

  • フォントは モリサワUD を最優先: 商用の UD黎ミン/UD新ゴ (Morisawa Fonts) がインストールされていればそれを使い、無ければ BIZ UD → ヒラギノ/Noto の順で フォールバック。--embed-fonts DIR で BIZ UD の woff2 (SIL OFL) を HTML に 埋め込めば、フォントの無い相手の環境でも同じ見た目になる
  • 日本語組版CSS を同梱: 本文は明朝・両端揃え・段落頭一字下げ・行間1.9、 見出しはゴシック、行頭禁則 (line-break: strict)、約物の行頭詰め (text-spacing-trim)、句読点のぶら下げ
  • CJKフレンドリーな Markdown 解釈 (mdit-py-cjk-friendly): 文中改行が空白にならない・全角括弧に隣接した強調が効く
  • 印刷/PDF対応: @page で A4・余白・ページ番号。表・コード・見出しの ページまたぎを抑止。--pdf は Chrome ヘッドレスで生成 (追加依存なし)
  • 縦書きと原稿用紙: --vertical で右→左の縦組 (縦中横つき)、 --genko で1字1マスの原稿用紙 (縦横両対応)
  • ふりがな: {漢字|かんじ} (グループルビ)・{東京|とう|きょう} (モノルビ) — でんでんマークダウン形式。縦書きでもそのまま効く
  • frontmatter (title / author / date) から表題部を生成

使い方

washi INPUT.md [-o OUTPUT.html] [--title 表題] [--pdf]
      [--theme default|textbook|gothic|maru|bungei]
      [--vertical] [--genko]
      [--font-serif NAME] [--font-sans NAME] [--webfonts]
      [--css FILE ...] [--no-base-css] [--embed-fonts DIR]

Python から:

from washi_md import render
html = render(markdown_text, title="報告書")

縦書き

washi 小説.md --vertical --theme bungei --pdf

--vertical で本文が縦書き (右→左) になる。1〜2桁の数字は自動で 縦中横、表とコードブロックは横書きのまま埋め込まれる。 bungei テーマと組み合わせると小説・随筆向けの組版になる。

原稿用紙にもできる (縦横どちらでも):

washi 作文.md --genko --pdf              # 横書き原稿用紙
washi 作文.md --genko --vertical --pdf   # 縦書き原稿用紙 (20字/行)

1字1マスのグリッドに全角ベタ組で流し込む。半角英数は自動で全角化。 字数を変えるには --cssbody.genko { --genko-cols: 25; } を渡す。

テーマとカスタムCSS

  • --theme textbook — 本文をUDデジタル教科書体に (学習教材向け。行間2.0)
  • --theme gothic — 本文ゴシック・字下げなし (ビジネス文書・報告書風)
  • --theme maru丸ゴシック (Zen Maru Gothic。お知らせ・案内文のやわらかい文書)
  • --theme bungeiオールド明朝 (Shippori Mincho。文芸・随筆の趣)
  • --webfonts — Google Fonts を読み込み、フォント未導入の環境でもテーマの 書体で表示 (BIZ UD も Google Fonts にあるため default テーマにも効く。 オフラインでは効かないので、自己完結にしたい場合は --embed-fonts を使う)
  • --font-serif "A1明朝" / --font-sans "新ゴ M"インストール済みフォントを 名前で直接指定。Morisawa Fonts (Select 8 等) で入れた書体がCSSなしで使える。 PDF生成もローカルレンダリングなのでそのまま効く
  • ユーザーテーマ: ~/.config/washi-md/themes/○○.css に置くと --theme ○○ で使える (同名なら同梱テーマより優先)。お気に入りの 書体構成を場面別に保存しておける
  • --css my.css — 自分のCSSを同梱CSSの後に追加 (自分のルールが優先。繰り返し可)
  • --no-base-css — 同梱CSSを使わず完全に自分のCSSで組む
from washi_md import render
html = render(md_text, theme="textbook", extra_css=[Path("my.css")])

ロードマップ

  • docx 出力 (美しい日本語 reference-doc)
  • AI が出力した Markdown の整形 (フォーマッタ)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

washi_md-0.8.0.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

washi_md-0.8.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file washi_md-0.8.0.tar.gz.

File metadata

  • Download URL: washi_md-0.8.0.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for washi_md-0.8.0.tar.gz
Algorithm Hash digest
SHA256 445a5deb59de7f02e2a3f6bc75571f63f174befe493802077dbef6329f7051eb
MD5 3d99949c39eea980d2b7b5dfc908ad51
BLAKE2b-256 a9db19432e74a3270ac9cd8d88ec6e769588a9dcd9323bdbaed76d1aba32ca5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for washi_md-0.8.0.tar.gz:

Publisher: publish.yml on aiseed-dev/washi-md

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file washi_md-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: washi_md-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for washi_md-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 967f6b0144a6e0b5428509d80c1b68010579a85e3094a7a4e9498b70b3aef20c
MD5 6b114b6f2e1f5ab36ced92a9097b3f58
BLAKE2b-256 9829fd08d2deb61880e276cccd374f75b81ab383b90b062b81d8be1de1187172

See more details on using hashes here.

Provenance

The following attestation bundles were made for washi_md-0.8.0-py3-none-any.whl:

Publisher: publish.yml on aiseed-dev/washi-md

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page