mkdocs-md-to-pdf 0.1.0__tar.gz → 0.1.2__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.
@@ -1,13 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocs-md-to-pdf
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Convert Markdown files to PDF using MkDocs Material theme and Playwright
5
+ Keywords: markdown,pdf,mkdocs,converter,documentation
6
+ Author: Lode Rosseel
5
7
  Author-email: Lode Rosseel <lode.rosseel@cegeka.com>
6
8
  License-Expression: MIT
7
- Project-URL: Homepage, https://github.com/lode-braced/mkdocs-md-to-pdf
8
- Project-URL: Repository, https://github.com/lode-braced/mkdocs-md-to-pdf
9
- Project-URL: Issues, https://github.com/lode-braced/mkdocs-md-to-pdf/issues
10
- Keywords: markdown,pdf,mkdocs,converter,documentation
11
9
  Classifier: Development Status :: 4 - Beta
12
10
  Classifier: Environment :: Console
13
11
  Classifier: Intended Audience :: Developers
@@ -17,19 +15,20 @@ Classifier: Programming Language :: Python :: 3.12
17
15
  Classifier: Programming Language :: Python :: 3.13
18
16
  Classifier: Topic :: Documentation
19
17
  Classifier: Topic :: Text Processing :: Markup :: Markdown
20
- Requires-Python: >=3.12
21
- Description-Content-Type: text/markdown
22
- License-File: LICENSE
23
18
  Requires-Dist: mkdocs>=1.6.1
24
19
  Requires-Dist: mkdocs-material>=9.6
25
20
  Requires-Dist: playwright>=1.42
26
21
  Requires-Dist: pymdown-extensions>=10.14
27
22
  Requires-Dist: plantuml-markdown>=3.11
28
23
  Requires-Dist: mkdocs-callouts>=1.16
24
+ Requires-Dist: pytest>=8.0 ; extra == 'dev'
25
+ Requires-Dist: pytest-mock>=3.14 ; extra == 'dev'
26
+ Requires-Python: >=3.12
27
+ Project-URL: Homepage, https://github.com/lode-braced/mkdocs-md-to-pdf
28
+ Project-URL: Repository, https://github.com/lode-braced/mkdocs-md-to-pdf
29
+ Project-URL: Issues, https://github.com/lode-braced/mkdocs-md-to-pdf/issues
29
30
  Provides-Extra: dev
30
- Requires-Dist: pytest>=8.0; extra == "dev"
31
- Requires-Dist: pytest-mock>=3.14; extra == "dev"
32
- Dynamic: license-file
31
+ Description-Content-Type: text/markdown
33
32
 
34
33
  # mkdocs-md-to-pdf
35
34
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mkdocs-md-to-pdf"
3
- version = "0.1.0"
3
+ version = "0.1.2"
4
4
  description = "Convert Markdown files to PDF using MkDocs Material theme and Playwright"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -44,5 +44,12 @@ Repository = "https://github.com/lode-braced/mkdocs-md-to-pdf"
44
44
  Issues = "https://github.com/lode-braced/mkdocs-md-to-pdf/issues"
45
45
 
46
46
 
47
+ [build-system]
48
+ requires = ["uv_build>=0.5.15"]
49
+ build-backend = "uv_build"
50
+
51
+ [tool.uv.build-backend]
52
+ module-root = "src"
53
+
47
54
  [tool.pytest.ini_options]
48
55
  testpaths = ["tests"]
@@ -14,7 +14,8 @@ def main() -> None:
14
14
  )
15
15
  parser.add_argument("input_file", help="Path to the markdown file to convert")
16
16
  parser.add_argument(
17
- "-o", "--output",
17
+ "-o",
18
+ "--output",
18
19
  help="Output PDF file path (default: write to stdout)",
19
20
  )
20
21
  args = parser.parse_args()
@@ -5,6 +5,7 @@ import os
5
5
  import re
6
6
  import shutil
7
7
  import subprocess
8
+ import sys
8
9
  import tempfile
9
10
  import time
10
11
  from pathlib import Path
@@ -14,9 +15,11 @@ from playwright.sync_api import sync_playwright
14
15
 
15
16
  def _get_template_content() -> str:
16
17
  """Load the mkdocs.yml template from package resources."""
17
- return importlib.resources.files("mkdocs_md_to_pdf").joinpath(
18
- "mkdocs.yml.template"
19
- ).read_text()
18
+ return (
19
+ importlib.resources.files("mkdocs_md_to_pdf")
20
+ .joinpath("mkdocs.yml.template")
21
+ .read_text()
22
+ )
20
23
 
21
24
 
22
25
  def _create_temp_mkdocs_config(input_file: Path, temp_dir: Path) -> Path:
@@ -36,9 +39,9 @@ def _create_temp_mkdocs_config(input_file: Path, temp_dir: Path) -> Path:
36
39
  if linked_file_path.is_file():
37
40
  shutil.copy2(linked_file_path, temp_docs_dir)
38
41
 
39
- config_content = template_content.replace(
40
- "{{site_name}}", input_file.name
41
- ).replace("{{docs_dir}}", "docs")
42
+ config_content = template_content.replace("{{site_name}}", input_file.name).replace(
43
+ "{{docs_dir}}", "docs"
44
+ )
42
45
 
43
46
  temp_config_path = temp_dir / "mkdocs.yml"
44
47
  temp_config_path.write_text(config_content)
@@ -67,10 +70,13 @@ def _extract_linked_files(input_file: Path) -> list[str]:
67
70
 
68
71
  def _serve_mkdocs(temp_dir: Path, port: int = 8765) -> subprocess.Popen:
69
72
  """Build and serve the mkdocs site."""
70
- subprocess.run(["mkdocs", "build"], cwd=temp_dir, check=True, capture_output=True)
73
+ mkdocs_cmd = [sys.executable, "-m", "mkdocs"]
74
+ subprocess.run(
75
+ [*mkdocs_cmd, "build"], cwd=temp_dir, check=True, capture_output=True
76
+ )
71
77
 
72
78
  server_process = subprocess.Popen(
73
- ["mkdocs", "serve", "-a", f"127.0.0.1:{port}"],
79
+ [*mkdocs_cmd, "serve", "-a", f"127.0.0.1:{port}"],
74
80
  cwd=temp_dir,
75
81
  stdout=subprocess.PIPE,
76
82
  stderr=subprocess.PIPE,
@@ -0,0 +1,44 @@
1
+ site_name: {{site_name}}
2
+ remote_branch: pages
3
+ theme:
4
+ name: material
5
+ palette:
6
+ # Palette toggle for automatic mode
7
+ - media: "(prefers-color-scheme)"
8
+ toggle:
9
+ icon: material/brightness-auto
10
+ name: Switch to light mode
11
+ - media: "(prefers-color-scheme: light)"
12
+ scheme: default
13
+ toggle:
14
+ icon: material/brightness-7
15
+ name: "Switch to dark mode"
16
+ - media: "(prefers-color-scheme: dark)"
17
+ scheme: slate
18
+ toggle:
19
+ icon: material/brightness-4
20
+ name: "Switch to System preference"
21
+ features:
22
+ - navigation.tabs
23
+
24
+
25
+ markdown_extensions:
26
+ - admonition
27
+ - pymdownx.details
28
+ - pymdownx.blocks.caption
29
+ - pymdownx.superfences:
30
+ custom_fences:
31
+ - name: mermaid
32
+ class: mermaid
33
+ format: !!python/name:pymdownx.superfences.fence_code_format
34
+ - pymdownx.details
35
+ - pymdownx.highlight:
36
+ pygments_lang_class: true
37
+ - plantuml_markdown:
38
+ format: svg
39
+ cachedir: /tmp/puml
40
+
41
+ plugins:
42
+ - callouts
43
+
44
+ docs_dir: {{docs_dir}}
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Lode Rosseel
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,117 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: mkdocs-md-to-pdf
3
- Version: 0.1.0
4
- Summary: Convert Markdown files to PDF using MkDocs Material theme and Playwright
5
- Author-email: Lode Rosseel <lode.rosseel@cegeka.com>
6
- License-Expression: MIT
7
- Project-URL: Homepage, https://github.com/lode-braced/mkdocs-md-to-pdf
8
- Project-URL: Repository, https://github.com/lode-braced/mkdocs-md-to-pdf
9
- Project-URL: Issues, https://github.com/lode-braced/mkdocs-md-to-pdf/issues
10
- Keywords: markdown,pdf,mkdocs,converter,documentation
11
- Classifier: Development Status :: 4 - Beta
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.12
17
- Classifier: Programming Language :: Python :: 3.13
18
- Classifier: Topic :: Documentation
19
- Classifier: Topic :: Text Processing :: Markup :: Markdown
20
- Requires-Python: >=3.12
21
- Description-Content-Type: text/markdown
22
- License-File: LICENSE
23
- Requires-Dist: mkdocs>=1.6.1
24
- Requires-Dist: mkdocs-material>=9.6
25
- Requires-Dist: playwright>=1.42
26
- Requires-Dist: pymdown-extensions>=10.14
27
- Requires-Dist: plantuml-markdown>=3.11
28
- Requires-Dist: mkdocs-callouts>=1.16
29
- Provides-Extra: dev
30
- Requires-Dist: pytest>=8.0; extra == "dev"
31
- Requires-Dist: pytest-mock>=3.14; extra == "dev"
32
- Dynamic: license-file
33
-
34
- # mkdocs-md-to-pdf
35
-
36
- Convert Markdown files to styled PDFs using [MkDocs Material](https://squidfunk.github.io/mkdocs-material/) theme and [Playwright](https://playwright.dev/).
37
-
38
- ## Features
39
-
40
- - Material Design styling via MkDocs Material theme
41
- - Syntax highlighting for code blocks
42
- - Mermaid diagram support
43
- - PlantUML diagram support (requires Java)
44
- - Admonitions and callouts
45
- - Automatic handling of linked images and files
46
-
47
- ## Installation
48
-
49
- ```bash
50
- # Using uv
51
- uv add mkdocs-md-to-pdf
52
-
53
- # Using pip
54
- pip install mkdocs-md-to-pdf
55
- ```
56
-
57
- After installation, install the Chromium browser for Playwright:
58
-
59
- ```bash
60
- playwright install chromium
61
- ```
62
-
63
- ### PlantUML Setup
64
-
65
- #### macOS
66
- 1. Download PlantUML JAR from [GitHub releases](https://github.com/plantuml/plantuml/releases/latest)
67
- 2. Place JAR: `mv plantuml-mit-1.2025.8.jar ~/.local/bin/plantuml.jar`
68
- 3. Make executable: `chmod +x ~/.local/bin/plantuml.jar`
69
- 4. Add to shell profile (.bashrc/.zshrc):
70
- ```bash
71
- export PATH="$PATH:~/.local/bin"
72
- export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"
73
- ```
74
-
75
- #### Ubuntu/Debian
76
- ```bash
77
- sudo apt install default-jdk plantuml
78
- ```
79
-
80
- ## Usage
81
-
82
- ### Command Line
83
-
84
- ```bash
85
- # Output to stdout (pipe to file)
86
- md-to-pdf document.md > output.pdf
87
-
88
- # Output to specific file
89
- md-to-pdf document.md -o output.pdf
90
- ```
91
-
92
- ### Python API
93
-
94
- ```python
95
- from mkdocs_md_to_pdf import convert
96
-
97
- # Get PDF as bytes
98
- pdf_bytes = convert("document.md")
99
-
100
- # Write directly to file
101
- convert("document.md", output_file="output.pdf")
102
- ```
103
-
104
- ## Supported Markdown Features
105
-
106
- - Standard Markdown syntax
107
- - Fenced code blocks with syntax highlighting
108
- - Tables
109
- - Admonitions (`!!! note`, `!!! warning`, etc.)
110
- - Callouts (`> [!NOTE]`, `> [!WARNING]`)
111
- - Mermaid diagrams
112
- - PlantUML diagrams
113
- - Linked images (relative paths)
114
-
115
- ## License
116
-
117
- MIT
@@ -1,4 +0,0 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
@@ -1,13 +0,0 @@
1
- LICENSE
2
- README.md
3
- pyproject.toml
4
- src/mkdocs_md_to_pdf/__init__.py
5
- src/mkdocs_md_to_pdf/cli.py
6
- src/mkdocs_md_to_pdf/converter.py
7
- src/mkdocs_md_to_pdf.egg-info/PKG-INFO
8
- src/mkdocs_md_to_pdf.egg-info/SOURCES.txt
9
- src/mkdocs_md_to_pdf.egg-info/dependency_links.txt
10
- src/mkdocs_md_to_pdf.egg-info/entry_points.txt
11
- src/mkdocs_md_to_pdf.egg-info/requires.txt
12
- src/mkdocs_md_to_pdf.egg-info/top_level.txt
13
- tests/test_converter.py
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- md-to-pdf = mkdocs_md_to_pdf.cli:main
@@ -1,10 +0,0 @@
1
- mkdocs>=1.6.1
2
- mkdocs-material>=9.6
3
- playwright>=1.42
4
- pymdown-extensions>=10.14
5
- plantuml-markdown>=3.11
6
- mkdocs-callouts>=1.16
7
-
8
- [dev]
9
- pytest>=8.0
10
- pytest-mock>=3.14
@@ -1 +0,0 @@
1
- mkdocs_md_to_pdf
@@ -1,48 +0,0 @@
1
- """Tests for the converter module."""
2
-
3
- import tempfile
4
- from pathlib import Path
5
-
6
- import pytest
7
-
8
- from mkdocs_md_to_pdf import __version__, convert
9
- from mkdocs_md_to_pdf.converter import _extract_linked_files, _get_template_content
10
-
11
-
12
- def test_version():
13
- assert __version__ == "0.1.0"
14
-
15
-
16
- def test_get_template_content():
17
- content = _get_template_content()
18
- assert "{{site_name}}" in content
19
- assert "{{docs_dir}}" in content
20
- assert "mkdocs-material" in content or "material" in content
21
-
22
-
23
- def test_extract_linked_files():
24
- with tempfile.NamedTemporaryFile(mode="w", suffix=".md", delete=False) as f:
25
- f.write("""
26
- # Test Document
27
-
28
- ![Image](image.png)
29
- [Link](other.md)
30
- [External](https://example.com)
31
- [Anchor](#section)
32
- <img src="photo.jpg" alt="Photo">
33
- <img src="https://example.com/img.png" alt="External">
34
- """)
35
- f.flush()
36
-
37
- linked = _extract_linked_files(Path(f.name))
38
-
39
- assert "image.png" in linked
40
- assert "other.md" in linked
41
- assert "photo.jpg" in linked
42
- assert "https://example.com" not in linked
43
- assert "#section" not in linked
44
-
45
-
46
- def test_convert_file_not_found():
47
- with pytest.raises(FileNotFoundError):
48
- convert("/nonexistent/path/to/file.md")