Skip to main content

Convert network device PDF manuals to Markdown using PyMuPDF4LLM

Project description

NetMuPDF

ネットワーク機器のPDFマニュアルを、CodexやClaudeが参照しやすいMarkdownファイルへ変換するツールです。 PDFのしおりを活用して、階層的なセクションごとにMarkdownを生成します。

特徴

  • 指定したしおりレベルでMarkdownを分割
  • 最初のしおりより前のページを 000_front_matter.md に出力
  • 元PDFのページ境界を <!-- PDF_PAGE: 123 --> として保持
  • index.mdtoc_sections.csv を自動生成
  • 同じページを指す複数のしおりを1ファイルに集約
  • PyMuPDF4LLMによる見出し・表・段組みの解析
  • ページヘッダーとフッターの除去
  • 機種別プロファイルによる入力形式と実行例の整形
  • テキストを抽出できないページを警告として記録

OCRは行いません。画像だけで構成されたPDFには、事前にOCR処理が必要です。

使用方法

PyPIからインストールしてCLIを実行します。

pip install netmupdf
netmupdf manuals\manual.pdf --level 2

開発中の作業ツリーから実行する場合:

uv sync
uv run netmupdf manuals\manual.pdf --level 2

出力先を指定する場合:

uv run netmupdf manuals\manual.pdf --out output\manual --level 2

分割予定だけを確認する場合:

uv run netmupdf manuals\manual.pdf --level 2 --dry-run

空でない出力先へ書き込む場合:

uv run netmupdf manuals\manual.pdf --out output\manual --force

後処理プロファイル

--profileオプションで、機種別の後処理プロファイルを指定できます。

  • fitelnet: FITELnetコマンドリファレンス用 (F70コマンドリファレンス構成定義編/運用管理編で動作を確認しています。)
  • srs: SR-Sシリーズコマンドリファレンス用 (SR-S V14コマンドリファレンスで動作を確認しています。)
  • generic(default): 汎用的な後処理で、上記以外のPDFに適しています。

実行例:

uv run netmupdf f70_cmd_ope_ref.pdf --profile fitelnet
uv run netmupdf sr_s_cmd.pdf --profile srs

出力

manual_markdown/
├── 000_front_matter.md
├── 001_概要.md
├── 002_設定.md
├── index.md
└── toc_sections.csv

各Markdownには元PDF名、ページ範囲、しおり階層、ページ境界と抽出本文が 含まれます。index.md は全セクションへのリンク、toc_sections.csv は ページ範囲や警告を含む機械可読の一覧です。

制限事項

  • 入力は単一PDFのみです。
  • PDFにしおりと抽出可能な文字情報が必要です。
  • 複雑な表、段組み、図の配置は完全には再現されない場合があります。
  • パスワード保護されたPDFは変換できません。

テスト

uv run pytest
uv run tox

ビルド

uv build

手動リリース

PyPIへの公開は手動で行います。公開前に検証を通してから配布物を作成します。

uv sync --locked --group dev
uv run ruff format --check .
uv run ruff check .
uv run ty check
uv run pytest
uv build
uv run twine check dist/*

公開する場合はPyPIのAPIトークンを設定してからアップロードします。

$env:UV_PUBLISH_TOKEN="pypi-..."
uv publish

一度公開したバージョン番号は再利用できません。次回以降の公開では pyproject.tomlversion を更新してから配布物を作成してください。

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

netmupdf-0.1.0.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

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

netmupdf-0.1.0-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

Details for the file netmupdf-0.1.0.tar.gz.

File metadata

  • Download URL: netmupdf-0.1.0.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for netmupdf-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f2b68bf880324ee1ae5f9c83ff0296972e58b89e056a1837a29069c06dd5c222
MD5 0b0e7e12a0db1429f53855ab8146cbb0
BLAKE2b-256 99af25ed46ce9ce52b9d581cd0fafd3d6f58247a7aee39a5bf6dd6517fceddb3

See more details on using hashes here.

File details

Details for the file netmupdf-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: netmupdf-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 27.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for netmupdf-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd2f27bf3cf6eaafcb12d4db22639262adc8a49d0de6fc19a06e8be54349293e
MD5 9f1aae6c222918cee6046f35dade8c65
BLAKE2b-256 ce7a7dfb284d9339e6c11ddad3e8683c6410294ca66c0608fc96029728a161a1

See more details on using hashes here.

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