agent-markdown-pdf 0.2.2__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agent_markdown_pdf-0.4.0/PKG-INFO +572 -0
- agent_markdown_pdf-0.4.0/README.md +529 -0
- agent_markdown_pdf-0.4.0/agent_markdown_pdf.egg-info/PKG-INFO +572 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/agent_markdown_pdf.egg-info/SOURCES.txt +26 -1
- agent_markdown_pdf-0.4.0/agent_markdown_pdf.egg-info/requires.txt +17 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/api.py +15 -19
- agent_markdown_pdf-0.4.0/mdtopdf/core/browser.py +263 -0
- agent_markdown_pdf-0.4.0/mdtopdf/core/diagnostics.py +39 -0
- agent_markdown_pdf-0.4.0/mdtopdf/core/diagram_diagnostics.py +37 -0
- agent_markdown_pdf-0.4.0/mdtopdf/core/doctor.py +145 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/core/fonts.py +214 -36
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/core/html.py +10 -2
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/core/inline.py +42 -0
- agent_markdown_pdf-0.4.0/mdtopdf/core/katex.py +32 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/core/markdown.py +71 -237
- agent_markdown_pdf-0.4.0/mdtopdf/core/mermaid.py +38 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/core/obsidian.py +8 -5
- agent_markdown_pdf-0.4.0/mdtopdf/core/output.py +29 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/core/pdf.py +15 -20
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/mdtopdf_cli.py +122 -15
- agent_markdown_pdf-0.4.0/mdtopdf/skills/SKILL.md +89 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/themes/default.css +96 -54
- agent_markdown_pdf-0.4.0/mdtopdf/vendor/browser-render.js +18 -0
- agent_markdown_pdf-0.4.0/mdtopdf/vendor/diagram-render.js +120 -0
- agent_markdown_pdf-0.4.0/mdtopdf/vendor/page-layout.js +213 -0
- agent_markdown_pdf-0.4.0/mdtopdf/vendor/pele/LICENSE +40 -0
- agent_markdown_pdf-0.4.0/mdtopdf/vendor/pele/NOTICE.md +11 -0
- agent_markdown_pdf-0.4.0/mdtopdf/vendor/pele/pele.global.js +147 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/pyproject.toml +14 -6
- agent_markdown_pdf-0.4.0/tests/test_browser.py +108 -0
- agent_markdown_pdf-0.4.0/tests/test_browser_discovery.py +125 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/tests/test_core.py +89 -269
- agent_markdown_pdf-0.4.0/tests/test_decorations.py +164 -0
- agent_markdown_pdf-0.4.0/tests/test_dependency_diagnostics.py +47 -0
- agent_markdown_pdf-0.4.0/tests/test_diagram_diagnostics.py +164 -0
- agent_markdown_pdf-0.4.0/tests/test_diagram_layout.py +220 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/tests/test_full_e2e.py +20 -15
- agent_markdown_pdf-0.4.0/tests/test_macos_fonts.py +17 -0
- agent_markdown_pdf-0.4.0/tests/test_math_alignment.py +36 -0
- agent_markdown_pdf-0.4.0/tests/test_page_geometry.py +152 -0
- agent_markdown_pdf-0.4.0/tests/test_pdfium.py +83 -0
- agent_markdown_pdf-0.4.0/tests/test_pele.py +295 -0
- agent_markdown_pdf-0.4.0/tests/test_reliability.py +280 -0
- agent_markdown_pdf-0.4.0/tests/test_stdin.py +123 -0
- agent_markdown_pdf-0.4.0/tests/test_table_layout.py +170 -0
- agent_markdown_pdf-0.4.0/tests/test_theme_tokens.py +163 -0
- agent_markdown_pdf-0.2.2/PKG-INFO +0 -412
- agent_markdown_pdf-0.2.2/README.md +0 -371
- agent_markdown_pdf-0.2.2/agent_markdown_pdf.egg-info/PKG-INFO +0 -412
- agent_markdown_pdf-0.2.2/agent_markdown_pdf.egg-info/requires.txt +0 -13
- agent_markdown_pdf-0.2.2/mdtopdf/core/doctor.py +0 -366
- agent_markdown_pdf-0.2.2/mdtopdf/core/katex.py +0 -75
- agent_markdown_pdf-0.2.2/mdtopdf/core/mermaid.py +0 -181
- agent_markdown_pdf-0.2.2/mdtopdf/skills/SKILL.md +0 -107
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/LICENSE +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/agent_markdown_pdf.egg-info/dependency_links.txt +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/agent_markdown_pdf.egg-info/entry_points.txt +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/agent_markdown_pdf.egg-info/top_level.txt +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/__init__.py +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/__main__.py +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/core/__init__.py +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/LICENSE +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/contrib/mhchem.min.js +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_AMS-Regular.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Main-Bold.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Main-Italic.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Main-Italic.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Main-Regular.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Math-Italic.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Math-Italic.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Script-Regular.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Script-Regular.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Size1-Regular.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Size2-Regular.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Size3-Regular.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Size4-Regular.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/katex.min.css +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/mdtopdf/vendor/katex/dist/katex.min.js +0 -0
- {agent_markdown_pdf-0.2.2 → agent_markdown_pdf-0.4.0}/setup.cfg +0 -0
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agent-markdown-pdf
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Agent-friendly Markdown-to-PDF CLI with HTML preview and JSON diagnostics
|
|
5
|
+
Author: rainp
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/ABClize/mdtopdf
|
|
8
|
+
Project-URL: Repository, https://github.com/ABClize/mdtopdf
|
|
9
|
+
Project-URL: Issues, https://github.com/ABClize/mdtopdf/issues
|
|
10
|
+
Keywords: markdown,pdf,markdown-to-pdf,chromium,obsidian,cli,agent,automation,json
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Documentation
|
|
23
|
+
Classifier: Topic :: Printing
|
|
24
|
+
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: click>=8.0.0
|
|
29
|
+
Requires-Dist: markdown-it-py>=3.0.0
|
|
30
|
+
Requires-Dist: mdit-py-plugins>=0.4.0
|
|
31
|
+
Requires-Dist: pygments>=2.0.0
|
|
32
|
+
Requires-Dist: playwright<2,>=1.51
|
|
33
|
+
Requires-Dist: tinycss2>=1.4.0
|
|
34
|
+
Requires-Dist: fonttools[woff]>=4.59.2
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: build>=1.2.0; extra == "dev"
|
|
38
|
+
Requires-Dist: twine>=5.0.0; extra == "dev"
|
|
39
|
+
Requires-Dist: pypdfium2>=4.30.0; extra == "dev"
|
|
40
|
+
Requires-Dist: pillow>=10.0.0; extra == "dev"
|
|
41
|
+
Requires-Dist: tomli>=2.0; python_version < "3.11" and extra == "dev"
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
<h1 align="center">mdtopdf: Agent-friendly Markdown-to-PDF CLI</h1>
|
|
45
|
+
|
|
46
|
+
<p align="center">
|
|
47
|
+
<a href="https://github.com/ABClize/mdtopdf/blob/main/README_CN.md">中文文档</a> |
|
|
48
|
+
<a href="https://github.com/ABClize/mdtopdf/blob/main/README.es-ES.md">Español</a>
|
|
49
|
+
</p>
|
|
50
|
+
|
|
51
|
+
<p align="center">
|
|
52
|
+
<a href="#quick-start"><img src="https://img.shields.io/badge/Quick_Start-2_min-blue?style=for-the-badge" alt="Quick Start"></a>
|
|
53
|
+
<a href="#agent-workflow"><img src="https://img.shields.io/badge/Agent_Friendly-JSON_Output-green?style=for-the-badge" alt="Agent Friendly"></a>
|
|
54
|
+
<a href="#visual-output"><img src="https://img.shields.io/badge/PDF_Pages-Rendered-purple?style=for-the-badge" alt="Rendered PDF pages"></a>
|
|
55
|
+
<a href="https://pypi.org/project/agent-markdown-pdf/"><img src="https://img.shields.io/pypi/v/agent_markdown_pdf.svg?style=for-the-badge" alt="PyPI version"></a>
|
|
56
|
+
<a href="https://github.com/ABClize/mdtopdf/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow?style=for-the-badge" alt="License"></a>
|
|
57
|
+
</p>
|
|
58
|
+
|
|
59
|
+
<p align="center">
|
|
60
|
+
<img src="https://img.shields.io/pypi/pyversions/agent_markdown_pdf.svg" alt="Python versions">
|
|
61
|
+
<img src="https://img.shields.io/badge/output-JSON_%2B_Human-blueviolet" alt="JSON and human output">
|
|
62
|
+
<img src="https://img.shields.io/badge/backend-Chromium-2f855a" alt="Chromium backend">
|
|
63
|
+
<img src="https://img.shields.io/badge/status-alpha-f59e0b" alt="Alpha status">
|
|
64
|
+
</p>
|
|
65
|
+
|
|
66
|
+
**One command** gives agents a controlled Markdown-to-PDF path.
|
|
67
|
+
|
|
68
|
+
<p align="center">
|
|
69
|
+
<img src="https://raw.githubusercontent.com/ABClize/mdtopdf/main/assets/readme/cover.png" alt="mdtopdf cover" width="900">
|
|
70
|
+
</p>
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Why it works for agents
|
|
75
|
+
|
|
76
|
+
Agents are good at writing Markdown. The problem is the handoff: PDFs exported
|
|
77
|
+
through ad hoc paths rarely share the same style. `mdtopdf` gives the user a
|
|
78
|
+
command-line interface where the style can be defined up front.
|
|
79
|
+
|
|
80
|
+
- **Agent-friendly** - `mdtopdf --help` is an interface description an agent can read.
|
|
81
|
+
- **JSON when it matters** - conversion, HTML preview, environment checks, and theme listing can return machine-readable output.
|
|
82
|
+
- **Local files in, local files out** - an isolated headless browser, no upload step, no remote rendering service.
|
|
83
|
+
- **More than plain Markdown** - Obsidian links, highlights, frontmatter, comments, and callouts are rendered.
|
|
84
|
+
|
|
85
|
+
## Quick start
|
|
86
|
+
|
|
87
|
+
Install from PyPI in your Python environment:
|
|
88
|
+
|
|
89
|
+
```shell
|
|
90
|
+
python -m pip install "agent-markdown-pdf>=0.4.0"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The PyPI distribution is `agent-markdown-pdf`; it installs the `mdtopdf` command.
|
|
94
|
+
Do not use `mdtopdf` as the PyPI package name; the distribution name is
|
|
95
|
+
intentionally different from the command name.
|
|
96
|
+
|
|
97
|
+
| Use case | Name |
|
|
98
|
+
| --- | --- |
|
|
99
|
+
| Install from PyPI | `agent-markdown-pdf` |
|
|
100
|
+
| Run the CLI | `mdtopdf` |
|
|
101
|
+
| Import in Python | `mdtopdf` |
|
|
102
|
+
|
|
103
|
+
Check the machine before the first conversion:
|
|
104
|
+
|
|
105
|
+
```shell
|
|
106
|
+
mdtopdf doctor --render-check --json
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The package installs the Python dependencies, including Playwright. You also need
|
|
110
|
+
a compatible Chromium browser and the fonts your documents use. An installed
|
|
111
|
+
Chrome, Edge, or Chromium is discovered automatically; if none is found, follow
|
|
112
|
+
[Browser setup](#browser-setup). This check actually renders PDF, math, and diagrams.
|
|
113
|
+
|
|
114
|
+
Convert a file:
|
|
115
|
+
|
|
116
|
+
```shell
|
|
117
|
+
mdtopdf convert report.md -o report.pdf --overwrite
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Try the bundled visual test document:
|
|
121
|
+
|
|
122
|
+
```shell
|
|
123
|
+
git clone https://github.com/ABClize/mdtopdf.git
|
|
124
|
+
cd mdtopdf
|
|
125
|
+
python -m pip install -e ".[dev]"
|
|
126
|
+
python -m playwright install chromium --no-shell
|
|
127
|
+
mdtopdf html examples/visual-test-en.md -o visual-test-en.html --overwrite
|
|
128
|
+
mdtopdf convert examples/visual-test-en.md -o visual-test-en.pdf --overwrite --json
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The same visual test is also available in Chinese at
|
|
132
|
+
`examples/visual-test-cn.md`.
|
|
133
|
+
|
|
134
|
+
## Updating
|
|
135
|
+
|
|
136
|
+
There is no `mdtopdf update` command. For a pip-installed release, activate the
|
|
137
|
+
same virtual environment (or select the same Python interpreter) used to install it:
|
|
138
|
+
|
|
139
|
+
```shell
|
|
140
|
+
python -m pip install --upgrade agent-markdown-pdf
|
|
141
|
+
python -m mdtopdf --version
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
This updates from the package index, not from the development branch.
|
|
145
|
+
For pipx or uv tool installations, use that tool's upgrade workflow instead.
|
|
146
|
+
For editable/source installs, update the intended checkout and reinstall from it;
|
|
147
|
+
do not replace a development install with a PyPI release by accident.
|
|
148
|
+
|
|
149
|
+
Pin a tested version in your deployment requirements rather than upgrading on
|
|
150
|
+
every job. After upgrading to 0.3.0 or later, run `mdtopdf doctor --render-check --json`
|
|
151
|
+
and review a representative PDF. If Playwright now needs a different managed
|
|
152
|
+
browser, follow [Browser setup](#browser-setup). Conversion does not check for
|
|
153
|
+
updates or upgrade the package/browser automatically.
|
|
154
|
+
|
|
155
|
+
## Agent workflow
|
|
156
|
+
|
|
157
|
+
The bundled agent skill lives at
|
|
158
|
+
[`mdtopdf/skills/SKILL.md`](https://github.com/ABClize/mdtopdf/blob/main/mdtopdf/skills/SKILL.md).
|
|
159
|
+
Use that file when another agent needs a compact runtime guide for `mdtopdf`.
|
|
160
|
+
|
|
161
|
+
```shell
|
|
162
|
+
mdtopdf doctor --json
|
|
163
|
+
mdtopdf convert report.md -o report.pdf --overwrite --json
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Agents can also send UTF-8 Markdown directly to `convert -`, without saving an
|
|
167
|
+
input file. An explicit output file is required; PDF bytes are not written to stdout.
|
|
168
|
+
|
|
169
|
+
```shell
|
|
170
|
+
printf '# Report\n\nGenerated by an agent.\n' | mdtopdf convert - -o report.pdf --json
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
PowerShell (set the pipe encoding for non-ASCII text, especially in Windows PowerShell 5.1):
|
|
174
|
+
|
|
175
|
+
```powershell
|
|
176
|
+
$OutputEncoding = [System.Text.UTF8Encoding]::new($false)
|
|
177
|
+
'# Report' | mdtopdf convert - -o report.pdf --json
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Relative resources resolve from the working directory unless `--base-url` is set.
|
|
181
|
+
Use `--resource-dir` for bare attachment names and `--title` for the document title
|
|
182
|
+
and default header (otherwise `stdin`). JSON reports `input: "-"` and `source: "stdin"`.
|
|
183
|
+
Empty or non-UTF-8 input fails; `--overwrite` and `--strict` behave as with files.
|
|
184
|
+
The `html` command still takes a file path.
|
|
185
|
+
|
|
186
|
+
Use HTML preview when layout needs a quick look:
|
|
187
|
+
|
|
188
|
+
```shell
|
|
189
|
+
mdtopdf html report.md -o report.html --overwrite --json
|
|
190
|
+
mdtopdf convert report.md -o report.pdf --overwrite --json
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
`convert --json` returns the input path, output path, file size, theme, font
|
|
194
|
+
check summary, warnings, and render method. If conversion fails in JSON mode,
|
|
195
|
+
the error is structured enough for an agent to show the command, explain the
|
|
196
|
+
likely cause, and retry after a fix.
|
|
197
|
+
|
|
198
|
+
A successful conversion can still have warnings: a missing image, an unavailable
|
|
199
|
+
font, or an unsupported formula shown as source. Read `warnings` before handing over the PDF.
|
|
200
|
+
For jobs that must not accept these fallbacks:
|
|
201
|
+
|
|
202
|
+
```shell
|
|
203
|
+
mdtopdf convert report.md -o report.pdf --overwrite --strict --json
|
|
204
|
+
mdtopdf doctor --render-check --json
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
`--strict` leaves an existing output untouched when a diagnostic is raised.
|
|
208
|
+
It is also available for file-based HTML previews. Math and Mermaid are rendered
|
|
209
|
+
to static HTML/SVG in Chromium; plain HTML export does not start a browser and
|
|
210
|
+
does not check image loading. `doctor --render-check` tests PDF, KaTeX, and Mermaid
|
|
211
|
+
together. It checks runtime health, not visual parity across machines.
|
|
212
|
+
Exit codes are `0` for success, `1` for runtime or strict-check failures, and
|
|
213
|
+
`2` for invalid arguments. Missing fonts are advisory; a missing browser or
|
|
214
|
+
bundled renderer makes the basic doctor check fail.
|
|
215
|
+
|
|
216
|
+
## Visual output
|
|
217
|
+
|
|
218
|
+
The gallery below is rendered from the final PDF produced by
|
|
219
|
+
`examples/visual-test-en.md`. It shows the actual pages an agent can hand back
|
|
220
|
+
to a user: headings, callouts, tables, code, math, images, Mermaid, and
|
|
221
|
+
pagination. The images show the 0.4.0 renderer, with Pele diagrams
|
|
222
|
+
and Chromium PDF rendering.
|
|
223
|
+
|
|
224
|
+
| Page 1 | Page 2 |
|
|
225
|
+
| --- | --- |
|
|
226
|
+
| <img src="https://raw.githubusercontent.com/ABClize/mdtopdf/main/assets/readme/pdf-page-en-1.png" alt="PDF page 1" width="420"> | <img src="https://raw.githubusercontent.com/ABClize/mdtopdf/main/assets/readme/pdf-page-en-2.png" alt="PDF page 2" width="420"> |
|
|
227
|
+
| Page 3 | Page 4 |
|
|
228
|
+
| <img src="https://raw.githubusercontent.com/ABClize/mdtopdf/main/assets/readme/pdf-page-en-3.png" alt="PDF page 3" width="420"> | <img src="https://raw.githubusercontent.com/ABClize/mdtopdf/main/assets/readme/pdf-page-en-4.png" alt="PDF page 4" width="420"> |
|
|
229
|
+
| Page 5 | Page 6 |
|
|
230
|
+
| <img src="https://raw.githubusercontent.com/ABClize/mdtopdf/main/assets/readme/pdf-page-en-5.png" alt="PDF page 5" width="420"> | <img src="https://raw.githubusercontent.com/ABClize/mdtopdf/main/assets/readme/pdf-page-en-6.png" alt="PDF page 6" width="420"> |
|
|
231
|
+
|
|
232
|
+
## How it works
|
|
233
|
+
|
|
234
|
+
```text
|
|
235
|
+
Markdown -> markdown-it-py HTML -> theme/custom CSS -> Chromium PDF
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
One Chromium session renders formulas with bundled KaTeX and Mermaid code blocks
|
|
239
|
+
with bundled Pele, waits for fonts and images, and prints the PDF. No separate
|
|
240
|
+
Mermaid CLI, Node.js installation, WeasyPrint, or MSYS2 setup is needed. Browser
|
|
241
|
+
installation is an explicit setup step; conversion never downloads a browser.
|
|
242
|
+
|
|
243
|
+
### Mermaid diagrams with Pele
|
|
244
|
+
|
|
245
|
+
Keep using `mermaid` or `mmd` fenced code blocks:
|
|
246
|
+
|
|
247
|
+
````markdown
|
|
248
|
+
```mermaid
|
|
249
|
+
flowchart LR
|
|
250
|
+
A[Draft] --> B[Review] --> C[PDF]
|
|
251
|
+
```
|
|
252
|
+
````
|
|
253
|
+
|
|
254
|
+
Pele produces SVG for HTML preview and PDF. Diagram label formulas written as
|
|
255
|
+
`$$...$$` use the bundled KaTeX renderer. The default SVG theme matches the
|
|
256
|
+
document's soft lavender palette and Latin-first font stack, with pale purple
|
|
257
|
+
nodes, dark text, and gray-purple connectors.
|
|
258
|
+
|
|
259
|
+
To customize the document and diagram palette, pass a CSS file with `--css`:
|
|
260
|
+
|
|
261
|
+
```css
|
|
262
|
+
:root {
|
|
263
|
+
--mdtopdf-accent: #7352a6;
|
|
264
|
+
--mdtopdf-surface: #f3effa;
|
|
265
|
+
}
|
|
266
|
+
.mermaid-diagram {
|
|
267
|
+
--pele-border: #b5a2cf;
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Shared palette variables are `--mdtopdf-background`, `--mdtopdf-text`,
|
|
272
|
+
`--mdtopdf-heading`, `--mdtopdf-accent`, `--mdtopdf-muted`, `--mdtopdf-surface`,
|
|
273
|
+
`--mdtopdf-surface-alt`, `--mdtopdf-border`, and `--mdtopdf-critical`.
|
|
274
|
+
Heading levels 2–6 also have `--mdtopdf-heading-2` through `--mdtopdf-heading-6`.
|
|
275
|
+
Local `--pele-*` overrides still customize diagrams independently.
|
|
276
|
+
|
|
277
|
+
Diagram layout uses the configured `@page` size and margins, including named
|
|
278
|
+
pages. Before pagination, it conservatively uses the smallest available width
|
|
279
|
+
and height across matching first/left/right page styles. The source diagram
|
|
280
|
+
direction is preserved. This supports common print CSS; inspect the final PDF
|
|
281
|
+
when using more complex page rules.
|
|
282
|
+
|
|
283
|
+
If fitting a diagram makes its text smaller than approximately **8pt**, the
|
|
284
|
+
result includes a `diagram_text_too_small` warning with the diagram index and
|
|
285
|
+
estimated printed font size. Prefer a wider page, larger labels, or smaller
|
|
286
|
+
diagrams. To adjust the warning threshold, use
|
|
287
|
+
`.mermaid-diagram { --mdtopdf-diagram-min-font-size: 9pt; }` in your CSS.
|
|
288
|
+
This changes the check, not the font size. `--strict` rejects the warning and
|
|
289
|
+
preserves an existing output.
|
|
290
|
+
|
|
291
|
+
Diagram failures return `error_code: "diagram_render_failed"`, an actionable
|
|
292
|
+
`hint`, and `error_details` with Pele's code, the 1-based diagram index, and a
|
|
293
|
+
source excerpt. When the location can be established, `diagram_line`,
|
|
294
|
+
`diagram_column`, and `source_line` refer to the original diagram and Markdown;
|
|
295
|
+
`source_start_line` identifies the code block's first content line.
|
|
296
|
+
Pele's own `renderer_line` / `renderer_column` are kept separately because its
|
|
297
|
+
preprocessing can shift locations. Unknown locations are omitted, not guessed.
|
|
298
|
+
|
|
299
|
+
Pele has its own layout, so diagram geometry can change. Mermaid `theme` and
|
|
300
|
+
`themeVariables` settings do not set its colors; use the CSS variables above.
|
|
301
|
+
Arbitrary HTML labels and external Mermaid plugins are unsupported. Review
|
|
302
|
+
existing diagrams in HTML and the final PDF. See Pele's
|
|
303
|
+
[compatibility guide](https://pele.run/compatibility) and
|
|
304
|
+
[theme variables](https://pele.run/theming).
|
|
305
|
+
|
|
306
|
+
The bundled Pele **1.8.0** requires ASCII Sankey node names. Chinese node names,
|
|
307
|
+
including quoted names, fail to parse in this version.
|
|
308
|
+
|
|
309
|
+
Use `examples/pele-compatibility.md` with its companion CSS to review diagram output:
|
|
310
|
+
|
|
311
|
+
```shell
|
|
312
|
+
mdtopdf html examples/pele-compatibility.md --css examples/pele-compatibility.css -o pele-compatibility.html --overwrite
|
|
313
|
+
mdtopdf convert examples/pele-compatibility.md --css examples/pele-compatibility.css -o pele-compatibility.pdf --overwrite
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### Upgrading from 0.2.x
|
|
317
|
+
|
|
318
|
+
The command name and Python API stay the same, but the PDF engine changes from
|
|
319
|
+
WeasyPrint to Chromium. There is no WeasyPrint fallback. Install/check the browser,
|
|
320
|
+
then render a representative document before upgrading an automated workflow.
|
|
321
|
+
Page breaks, headers/footers, fonts, and custom paged-media CSS may differ.
|
|
322
|
+
JSON consumers should accept the new render-method value rather than hard-code
|
|
323
|
+
the old backend. See the [release notes](https://github.com/ABClize/mdtopdf/blob/main/CHANGELOG.md).
|
|
324
|
+
|
|
325
|
+
## Features
|
|
326
|
+
|
|
327
|
+
| Feature | Notes |
|
|
328
|
+
| --- | --- |
|
|
329
|
+
| JSON output | `--json` is available for conversion, HTML preview, doctor, and theme listing. |
|
|
330
|
+
| Environment checks | `doctor --json` checks Python imports, the browser executable, bundled KaTeX/Pele assets, and recommended fonts. |
|
|
331
|
+
| Local rendering | Markdown, CSS, math, Mermaid SVG generation, and PDF export stay on the machine. |
|
|
332
|
+
| HTML preview | Generate standalone HTML before PDF export for fast visual inspection. |
|
|
333
|
+
| Obsidian compatibility | Wikilinks, aliases, frontmatter hiding, comments, highlights, and typed callouts. |
|
|
334
|
+
| Document Markdown | Tables, task lists, footnotes, heading anchors, fenced code, and Pygments highlighting. |
|
|
335
|
+
| KaTeX math | Inline and block TeX render with bundled KaTeX assets, without a CDN. |
|
|
336
|
+
| Safe HTML default | Common inline document tags are allowed; unsafe raw HTML stays escaped unless opted in. |
|
|
337
|
+
| Python API | Convert Markdown strings or files from your own code. |
|
|
338
|
+
|
|
339
|
+
## Commands
|
|
340
|
+
|
|
341
|
+
Render a PDF:
|
|
342
|
+
|
|
343
|
+
```shell
|
|
344
|
+
mdtopdf convert report.md -o report.pdf
|
|
345
|
+
mdtopdf convert report.md -o report.pdf --overwrite
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
Preview HTML:
|
|
349
|
+
|
|
350
|
+
```shell
|
|
351
|
+
mdtopdf html report.md -o report.html --overwrite
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
Set document metadata and page chrome:
|
|
355
|
+
|
|
356
|
+
```shell
|
|
357
|
+
mdtopdf convert report.md -o report.pdf --title "Report"
|
|
358
|
+
mdtopdf convert report.md -o report.pdf --header "Report" --footer "Draft"
|
|
359
|
+
mdtopdf convert report.md -o report.pdf --no-header --no-footer
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Use extra CSS or resource lookup paths:
|
|
363
|
+
|
|
364
|
+
```shell
|
|
365
|
+
mdtopdf convert report.md -o report.pdf --css print.css
|
|
366
|
+
mdtopdf convert report.md -o report.pdf --base-url assets
|
|
367
|
+
mdtopdf convert report.md -o report.pdf --resource-dir attachments
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
Custom CSS is the style extension point. Put document-specific rules in a CSS
|
|
371
|
+
file; fonts, spacing, colors, page rules, and code block styling all live there.
|
|
372
|
+
Use a system-installed font directly, or define `@font-face` for a local font
|
|
373
|
+
file. Relative URLs in CSS are resolved from the Markdown file's base URL, so
|
|
374
|
+
use `--base-url` when those assets live next to your document:
|
|
375
|
+
|
|
376
|
+
```css
|
|
377
|
+
@font-face {
|
|
378
|
+
font-family: "Report Sans";
|
|
379
|
+
src: url("fonts/NotoSansSC-Regular.otf");
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
:root {
|
|
383
|
+
font-family: "Report Sans", "Noto Sans SC", "Source Han Sans SC", sans-serif;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
code,
|
|
387
|
+
pre {
|
|
388
|
+
font-family: "Cascadia Code", "Liberation Mono", monospace;
|
|
389
|
+
}
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
Then pass the CSS file:
|
|
393
|
+
|
|
394
|
+
```shell
|
|
395
|
+
mdtopdf convert report.md -o report.pdf --css print.css --base-url .
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
During export, `mdtopdf` checks the final CSS font stacks. Missing fonts do not
|
|
399
|
+
stop PDF generation, but they are reported in CLI warnings and in the JSON
|
|
400
|
+
`warnings` field.
|
|
401
|
+
Custom CSS also warns when its first named font is missing, even if a fallback
|
|
402
|
+
is available. Local `@font-face` files are checked for readability and CJK
|
|
403
|
+
coverage; declaring a family is not enough. Remote font sources are not fetched
|
|
404
|
+
by this static check and are reported as unverified. These checks do not replace
|
|
405
|
+
reviewing the rendered PDF. Pass `--strict` to reject warnings.
|
|
406
|
+
|
|
407
|
+
Return JSON:
|
|
408
|
+
|
|
409
|
+
```shell
|
|
410
|
+
mdtopdf --json convert report.md -o report.pdf --overwrite
|
|
411
|
+
mdtopdf doctor --json
|
|
412
|
+
mdtopdf themes list --json
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
Allow raw HTML only for trusted local Markdown:
|
|
416
|
+
|
|
417
|
+
```shell
|
|
418
|
+
mdtopdf convert trusted.md -o trusted.pdf --unsafe-html
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
HTML filtering is not a filesystem or network sandbox. Images and CSS can still
|
|
422
|
+
reference local files or remote URLs. Run untrusted documents in an environment
|
|
423
|
+
with restricted filesystem access and networking.
|
|
424
|
+
|
|
425
|
+
## Python API
|
|
426
|
+
|
|
427
|
+
```python
|
|
428
|
+
from mdtopdf import (
|
|
429
|
+
markdown_file_to_html,
|
|
430
|
+
markdown_file_to_pdf,
|
|
431
|
+
markdown_to_html,
|
|
432
|
+
markdown_to_pdf,
|
|
433
|
+
)
|
|
434
|
+
|
|
435
|
+
rendered = markdown_to_html("# Report\n\n==highlight==")
|
|
436
|
+
print(rendered.html)
|
|
437
|
+
|
|
438
|
+
markdown_to_pdf("# Report\n\nBody", "report.pdf", title="Report", overwrite=True)
|
|
439
|
+
markdown_file_to_html("report.md", output_path="report.html", overwrite=True)
|
|
440
|
+
markdown_file_to_pdf("report.md", output_path="report.pdf", overwrite=True)
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
## Markdown support
|
|
444
|
+
|
|
445
|
+
`mdtopdf` supports:
|
|
446
|
+
|
|
447
|
+
- CommonMark
|
|
448
|
+
- Tables with content-based column widths and wrapping for long words and URLs
|
|
449
|
+
- Strikethrough
|
|
450
|
+
- Task lists
|
|
451
|
+
- Footnotes
|
|
452
|
+
- Heading anchors
|
|
453
|
+
- Fenced code blocks with Pygments highlighting
|
|
454
|
+
- Obsidian-style `==highlight==` marks
|
|
455
|
+
- Obsidian-style `[[target|alias]]` wikilinks
|
|
456
|
+
- Obsidian-style `%%comment%%` comments outside code
|
|
457
|
+
- Obsidian/YAML frontmatter hiding at the start of the file
|
|
458
|
+
- Obsidian-style callouts such as `> [!note] Title`
|
|
459
|
+
- Safe inline HTML tags such as `<br>`, `<kbd>`, `<mark>`, `<sup>`, and `<sub>`
|
|
460
|
+
- TeX math through `$inline$`, `$$block$$`, and common `amsmath` environments
|
|
461
|
+
- Mermaid code blocks through bundled Pele in Chromium
|
|
462
|
+
|
|
463
|
+
Raw HTML is disabled by default except for the safe subset above. For trusted
|
|
464
|
+
local Markdown, pass `--unsafe-html`.
|
|
465
|
+
|
|
466
|
+
## Browser setup
|
|
467
|
+
|
|
468
|
+
PDF export requires Chromium. HTML export also uses it when the document has
|
|
469
|
+
math or Mermaid. Browser selection is deterministic: `MDTOPDF_BROWSER_EXECUTABLE`,
|
|
470
|
+
then legacy `PUPPETEER_EXECUTABLE_PATH`, then installed Playwright Chromium,
|
|
471
|
+
then Chrome/Edge/Chromium on PATH or in common Windows/macOS installation folders.
|
|
472
|
+
Linux also checks standard installation paths. An invalid explicit path is an error,
|
|
473
|
+
not a reason to silently switch browsers. Discovery never downloads or installs anything.
|
|
474
|
+
|
|
475
|
+
If no browser is available, install the managed browser once:
|
|
476
|
+
|
|
477
|
+
```shell
|
|
478
|
+
python -m playwright install chromium --no-shell
|
|
479
|
+
mdtopdf doctor --render-check --json
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
`doctor --json` shows the selected path and its `tools.browser.source`.
|
|
483
|
+
Use `--render-check` to verify it actually launches and renders. A browser found
|
|
484
|
+
on disk can still lack required system libraries or sandbox support.
|
|
485
|
+
An existing recent Chrome or Edge can be selected explicitly:
|
|
486
|
+
|
|
487
|
+
```powershell
|
|
488
|
+
$env:MDTOPDF_BROWSER_EXECUTABLE = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
|
|
489
|
+
mdtopdf doctor --render-check --json
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
```shell
|
|
493
|
+
export MDTOPDF_BROWSER_EXECUTABLE="$(command -v google-chrome)"
|
|
494
|
+
mdtopdf doctor --render-check --json
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
The legacy `PUPPETEER_EXECUTABLE_PATH` is accepted if the new variable is unset.
|
|
498
|
+
A fresh headless session is used; your personal browser profile is never opened.
|
|
499
|
+
Browser errors include an `error_code`, original message, and repair `hint`.
|
|
500
|
+
|
|
501
|
+
## Platform notes
|
|
502
|
+
|
|
503
|
+
Use Python 3.10+ and a recent Chromium browser. The Python Playwright package
|
|
504
|
+
includes its driver; a separate Node.js or npm installation is not required.
|
|
505
|
+
Windows and macOS no longer need an MSYS2 or Homebrew Pango setup.
|
|
506
|
+
|
|
507
|
+
On a supported Debian/Ubuntu environment, install Chromium's system libraries
|
|
508
|
+
during setup, then provide the fonts your documents use:
|
|
509
|
+
|
|
510
|
+
```shell
|
|
511
|
+
python -m playwright install-deps chromium
|
|
512
|
+
sudo apt-get update
|
|
513
|
+
sudo apt-get install -y --no-install-recommends \
|
|
514
|
+
fontconfig fonts-liberation fonts-dejavu-core fonts-noto-cjk fonts-stix
|
|
515
|
+
fc-cache -f
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
Run conversions as a **non-root** user with working browser sandbox support.
|
|
519
|
+
If Ubuntu/AppArmor blocks a downloaded browser, use an explicitly configured
|
|
520
|
+
system Chrome permitted by the host policy. Do not fix this by disabling the
|
|
521
|
+
sandbox. See [Playwright browser setup](https://playwright.dev/python/docs/browsers).
|
|
522
|
+
|
|
523
|
+
The theme keeps Latin fonts before CJK fonts. Linux uses Liberation Sans /
|
|
524
|
+
DejaVu Sans for English and digits, Noto Sans CJK SC for Chinese, and Cascadia
|
|
525
|
+
Mono / Cascadia Code for code where installed (otherwise system monospace).
|
|
526
|
+
Debian provides Cascadia through `fonts-cascadia-code`. Windows keeps its
|
|
527
|
+
existing system font stack. Microsoft YaHei and Segoe UI Emoji are not Linux
|
|
528
|
+
requirements and are never downloaded or bundled by mdtopdf.
|
|
529
|
+
|
|
530
|
+
Emoji still use installed system fonts. The existing Linux preference is
|
|
531
|
+
monochrome Noto Emoji, with Noto Color Emoji as a fallback. Browser rendering
|
|
532
|
+
removes the old WeasyPrint pipeline, but does not make every font or emoji
|
|
533
|
+
sequence identical across operating systems. Review representative PDFs.
|
|
534
|
+
KaTeX includes its own math fonts; STIX is an optional math fallback.
|
|
535
|
+
|
|
536
|
+
Images, CSS, and fonts may use local or remote resources. Document JavaScript
|
|
537
|
+
is blocked during conversion, even with `--unsafe-html`; this is not a
|
|
538
|
+
filesystem or network sandbox. Use restricted filesystem/network permissions
|
|
539
|
+
for untrusted documents. Raw HTML exported with `--unsafe-html` remains trusted
|
|
540
|
+
content when opened elsewhere.
|
|
541
|
+
|
|
542
|
+
## Development
|
|
543
|
+
|
|
544
|
+
```shell
|
|
545
|
+
git clone https://github.com/ABClize/mdtopdf.git
|
|
546
|
+
cd mdtopdf
|
|
547
|
+
python -m pip install -e ".[dev]"
|
|
548
|
+
python -m playwright install chromium --no-shell
|
|
549
|
+
python -m pytest tests/ -q
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
Build and check the package:
|
|
553
|
+
|
|
554
|
+
```shell
|
|
555
|
+
python -m build
|
|
556
|
+
python -m twine check dist/*
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
## License
|
|
560
|
+
|
|
561
|
+
MIT. Bundled KaTeX and Pele assets include their MIT licenses at
|
|
562
|
+
`mdtopdf/vendor/katex/LICENSE` and `mdtopdf/vendor/pele/LICENSE`.
|
|
563
|
+
`mdtopdf/vendor/pele/LICENSE` also includes the Lucide ISC license.
|
|
564
|
+
Pele's bundled version, source, and asset hash are recorded in
|
|
565
|
+
`mdtopdf/vendor/pele/NOTICE.md`.
|
|
566
|
+
|
|
567
|
+
`mdtopdf` does not bundle CJK body fonts, emoji fonts, or proprietary system
|
|
568
|
+
fonts. The default theme references local system fonts such as Segoe UI,
|
|
569
|
+
Microsoft YaHei, PingFang SC, Segoe UI Emoji, Noto Sans CJK SC,
|
|
570
|
+
Noto Emoji, Noto Color Emoji, Cascadia Code, and Consolas, but those font files come from
|
|
571
|
+
the user's operating system or runtime environment. Public Linux images should
|
|
572
|
+
prefer the open-font baseline above.
|