Skip to main content

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

Project description

washi-md

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

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

# PyPI 公開までは GitHub から (依存パッケージを先に):
pip install "mdit-py-cjk-friendly @ git+https://github.com/aiseed-dev/mdit-py-cjk-friendly.git"
pip install "washi-md @ git+https://github.com/aiseed-dev/washi-md.git"
# PyPI 公開後: 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.7.0.tar.gz (19.1 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.7.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: washi_md-0.7.0.tar.gz
  • Upload date:
  • Size: 19.1 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.7.0.tar.gz
Algorithm Hash digest
SHA256 afe69c0d3b7c66fd783e9707b51599d9c273a9c18db2e66a081b48769577f825
MD5 43af3ae4f18187a968bf02129a9d7c5a
BLAKE2b-256 637c7579592520d1cc89c3529ccdc8ba0600c955b1625a3c092abb6af10af18c

See more details on using hashes here.

Provenance

The following attestation bundles were made for washi_md-0.7.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.7.0-py3-none-any.whl.

File metadata

  • Download URL: washi_md-0.7.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.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f96ff5557530284dd580eb848185317b0668cae0638664f5229154c89a83d43f
MD5 dd2e1fcc4dbdcce484ec5d4b476bdbd8
BLAKE2b-256 033fd19f63d75e86b2bbfded8aa1006da732378305f7021a27e684d40c02add3

See more details on using hashes here.

Provenance

The following attestation bundles were made for washi_md-0.7.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