mddoco 2.1.0__tar.gz → 2.2.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.
Files changed (45) hide show
  1. {mddoco-2.1.0/src/mddoco.egg-info → mddoco-2.2.0}/PKG-INFO +33 -4
  2. {mddoco-2.1.0 → mddoco-2.2.0}/README.md +287 -258
  3. {mddoco-2.1.0 → mddoco-2.2.0}/pyproject.toml +1 -1
  4. mddoco-2.2.0/src/mddoco/__init__.py +1 -0
  5. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco/cli.py +6 -1
  6. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco/pdf.py +20 -1
  7. mddoco-2.2.0/src/mddoco/renderer.py +57 -0
  8. mddoco-2.2.0/src/mddoco/themes/_site_base.html +382 -0
  9. mddoco-2.2.0/src/mddoco/themes/academic-wide.html +7 -0
  10. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco/themes/academic.html +3 -1
  11. mddoco-2.2.0/src/mddoco/themes/dark-wide.html +7 -0
  12. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco/themes/dark.html +8 -1
  13. mddoco-2.2.0/src/mddoco/themes/default-wide.html +7 -0
  14. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco/themes/default.html +8 -1
  15. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco/themes/paged-professional.html +30 -13
  16. mddoco-2.2.0/src/mddoco/themes/professional-wide.html +14 -0
  17. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco/themes/professional.html +9 -1
  18. mddoco-2.2.0/src/mddoco/themes/site-dark.html +37 -0
  19. mddoco-2.2.0/src/mddoco/themes/site-professional.html +67 -0
  20. mddoco-2.2.0/src/mddoco/themes/site-terminal.html +65 -0
  21. mddoco-2.2.0/src/mddoco/themes/site.html +8 -0
  22. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco/themes/vanilla.html +2 -1
  23. {mddoco-2.1.0 → mddoco-2.2.0/src/mddoco.egg-info}/PKG-INFO +33 -4
  24. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco.egg-info/SOURCES.txt +7 -1
  25. {mddoco-2.1.0 → mddoco-2.2.0}/tests/test_preprocessor.py +1 -1
  26. mddoco-2.2.0/tests/test_themes.py +63 -0
  27. mddoco-2.1.0/src/mddoco/__init__.py +0 -1
  28. mddoco-2.1.0/src/mddoco/renderer.py +0 -35
  29. mddoco-2.1.0/src/mddoco/themes/academic-wide.html +0 -191
  30. mddoco-2.1.0/src/mddoco/themes/dark-wide.html +0 -183
  31. mddoco-2.1.0/src/mddoco/themes/default-wide.html +0 -164
  32. mddoco-2.1.0/src/mddoco/themes/professional-wide.html +0 -228
  33. {mddoco-2.1.0 → mddoco-2.2.0}/LICENSE +0 -0
  34. {mddoco-2.1.0 → mddoco-2.2.0}/setup.cfg +0 -0
  35. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco/converter.py +0 -0
  36. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco/graph.py +0 -0
  37. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco/mermaid.py +0 -0
  38. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco/preprocessor.py +0 -0
  39. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco/scanner.py +0 -0
  40. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco/toc.py +0 -0
  41. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco/writer.py +0 -0
  42. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco.egg-info/dependency_links.txt +0 -0
  43. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco.egg-info/entry_points.txt +0 -0
  44. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco.egg-info/requires.txt +0 -0
  45. {mddoco-2.1.0 → mddoco-2.2.0}/src/mddoco.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mddoco
3
- Version: 2.1.0
3
+ Version: 2.2.0
4
4
  Summary: Markdown to HTML/PDF document converter
5
5
  Author-email: Phil Massyn <phil.massyn@icloud.com>
6
6
  Project-URL: Homepage, https://github.com/massyn/mddoco
@@ -93,7 +93,7 @@ All matched markdown files are combined into a single HTML document in the outpu
93
93
 
94
94
  ## Examples
95
95
 
96
- The [`examples/`](examples/) directory contains four runnable input folders, each
96
+ The [`examples/`](examples/) directory contains five runnable input folders, each
97
97
  covering a different feature:
98
98
 
99
99
  | Folder | Demonstrates |
@@ -102,6 +102,7 @@ covering a different feature:
102
102
  | [`examples/02_rich_content`](examples/02_rich_content) | Mermaid diagrams, syntax highlighting, `graph` charts |
103
103
  | [`examples/03_themed_report`](examples/03_themed_report) | Themes and a table of contents |
104
104
  | [`examples/04_jinja_data`](examples/04_jinja_data) | Jinja2 templates with JSON and CSV data files |
105
+ | [`examples/05_security_findings`](examples/05_security_findings) | CSV data grouped in a Jinja2 template and fed into a `graph` chart |
105
106
 
106
107
  ```bash
107
108
  mddoco examples/03_themed_report --theme professional --title "Q3 Platform Review" --toc --output ./out
@@ -181,7 +182,7 @@ Use `{% import %}` or `{% from ... import %}` to make macros from another file c
181
182
 
182
183
  ## Themes
183
184
 
184
- Themes are self-contained Jinja2 HTML files with embedded CSS. Pass a theme name with `--theme NAME`.
185
+ Themes are Jinja2 HTML files with embedded CSS. Pass a theme name with `--theme NAME`. The `-wide` and `site-*` themes extend another theme (`default.html`, `_site_base.html` and so on), so to customise one of those, copy the theme it extends as well.
185
186
 
186
187
  | Theme | Description |
187
188
  |---|---|
@@ -195,14 +196,42 @@ Themes are self-contained Jinja2 HTML files with embedded CSS. Pass a theme name
195
196
  | `academic-wide` | Same as `academic` but full viewport width |
196
197
  | `vanilla` | Minimal HTML with no styling — useful for testing or custom CSS |
197
198
  | `paged-professional` | Corporate style with Paged.js pagination for print-ready PDFs |
199
+ | `site` | Website layout: side nav with one page per H1, minimalist styling (HTML only) |
200
+ | `site-professional` | Same as `site` with a navy sidebar and card layout (HTML only) |
201
+ | `site-dark` | Same as `site` on a dark background (HTML only) |
202
+ | `site-terminal` | Same as `site` as a green-phosphor terminal, just for fun (HTML only) |
198
203
 
199
204
  All themes support:
200
205
 
201
206
  - Optional document title
202
- - Optional table of contents
207
+ - Optional table of contents (the `site-*` themes use their side nav instead)
203
208
  - [Mermaid.js](https://mermaid.js.org) diagram support (loaded only when diagrams are present)
204
209
  - Graph diagram blocks
205
210
 
211
+ ### Site themes
212
+
213
+ The `site-*` themes turn the output into a small website while keeping it a single HTML file: no web server needed, and it still works offline or as an email attachment.
214
+
215
+ ```bash
216
+ mddoco ./docs --theme site --title "Team Handbook" --output ./out
217
+ ```
218
+
219
+ - Every H1 starts a new page, and each page is listed in the side nav. Anything before the first H1 becomes an introduction page.
220
+ - The current page's H2 headings are listed under it in the nav.
221
+ - Only one page shows at a time, with previous/next links at the bottom. Each page has its own address (`handbook.html#/onboarding`, or `#/onboarding/first-week` for a heading), so the back button, bookmarks and shared links work.
222
+ - On narrow screens the nav moves behind a menu button.
223
+ - They are screen-only: `--format pdf` is refused. Printing from the browser still prints every page in sequence.
224
+
225
+ ### Screen-only custom themes
226
+
227
+ A custom theme can refuse PDF output by declaring this at the top level of its template:
228
+
229
+ ```jinja
230
+ {% set pdf_supported = false %}
231
+ ```
232
+
233
+ `--format pdf` with that theme then exits with an error instead of producing a PDF.
234
+
206
235
  ### Graph diagrams
207
236
 
208
237
  Use ` ```graph ` fenced blocks with a JSON payload. The only required field is `data`.
@@ -1,258 +1,287 @@
1
- # mddoco
2
-
3
- A CLI tool that converts markdown files to a single HTML (or future PDF) document.
4
-
5
- [![Publish to PyPI](https://github.com/massyn/mddoco/actions/workflows/ci.yml/badge.svg)](https://github.com/massyn/mddoco/actions/workflows/ci.yml)
6
- ![PyPI Version](https://img.shields.io/pypi/v/mddoco) ![PyPI Downloads](https://img.shields.io/pypi/dd/mddoco)
7
- ## Installation
8
-
9
- ```bash
10
- pip install mddoco
11
- ```
12
-
13
- Or for development:
14
-
15
- ```bash
16
- pip install -e .
17
- ```
18
-
19
- > **Playwright (Chromium) is required for PDF output only.** HTML output works without it.
20
- > The `playwright` Python package is installed automatically, but the Chromium
21
- > browser it drives is not. The first time you render a PDF, mddoco downloads
22
- > Chromium for you (~150 MB, one time). To do it ahead of time, or if the
23
- > automatic download fails, run it yourself:
24
- >
25
- > ```bash
26
- > playwright install chromium
27
- > ```
28
-
29
- ## Usage
30
-
31
- ```
32
- mddoco [OPTIONS] INPUT_PATH
33
- ```
34
-
35
- `INPUT_PATH` can be a **directory** (all `*.md` and `*.md.j2` files are found recursively and sorted together) or a **single `.md` or `.md.j2` file**.
36
-
37
- ### Options
38
-
39
- | Option | Short | Default | Description |
40
- |---|---|---|---|
41
- | `--output PATH` | `-o` | `.` | Directory to write the output file |
42
- | `--format [html\|pdf]` | `-f` | `html` | Output format |
43
- | `--title TEXT` | `-t` | _(none)_ | Document title shown at the top of the page |
44
- | `--theme NAME` | | `default` | Theme to use for rendering |
45
- | `--toc / --no-toc` | | off | Generate a table of contents |
46
- | `--toc-depth N` | | `3` | Maximum heading depth included in the TOC (1–6) |
47
-
48
- ### Examples
49
-
50
- Convert all markdown files in a directory:
51
-
52
- ```bash
53
- mddoco ./docs
54
- ```
55
-
56
- Convert a single file:
57
-
58
- ```bash
59
- mddoco README.md
60
- ```
61
-
62
- With a title, TOC, and custom output directory:
63
-
64
- ```bash
65
- mddoco ./docs --title "My Project" --toc --output ./out
66
- ```
67
-
68
- ## Output
69
-
70
- All matched markdown files are combined into a single HTML document in the output directory. The filename is derived from the input folder or file name.
71
-
72
- ## Examples
73
-
74
- The [`examples/`](examples/) directory contains four runnable input folders, each
75
- covering a different feature:
76
-
77
- | Folder | Demonstrates |
78
- |--------|--------------|
79
- | [`examples/01_basic`](examples/01_basic) | Plain Markdown, file ordering, underscore-excluded files |
80
- | [`examples/02_rich_content`](examples/02_rich_content) | Mermaid diagrams, syntax highlighting, `graph` charts |
81
- | [`examples/03_themed_report`](examples/03_themed_report) | Themes and a table of contents |
82
- | [`examples/04_jinja_data`](examples/04_jinja_data) | Jinja2 templates with JSON and CSV data files |
83
-
84
- ```bash
85
- mddoco examples/03_themed_report --theme professional --title "Q3 Platform Review" --toc --output ./out
86
- ```
87
-
88
- See [`examples/README.md`](examples/README.md) for the full list of commands.
89
-
90
- ## Jinja2 templates
91
-
92
- Files ending in `.md.j2` are Jinja2 templates that produce Markdown. They are sorted alongside regular `.md` files (numeric prefixes such as `01_`, `02_` determine order) and converted through the same pipeline.
93
-
94
- ### Context variables (JSON and CSV)
95
-
96
- Place `*.json` or `*.csv` files in the same input directory. Each file's stem becomes a top-level variable in the Jinja2 context — `report.json` is available as `report`, `people.csv` as `people`, and so on. If both `data.json` and `data.csv` exist, the tool will exit with an error.
97
-
98
- ```
99
- docs/
100
- 01_intro.md
101
- 02_summary.md.j2 ← Jinja2 template
102
- report.json ← available as {{ report }}
103
- people.csv ← available as {{ people }}
104
- ```
105
-
106
- **JSON** files are loaded as-is; the variable holds whatever structure the JSON contains.
107
-
108
- **CSV** files are loaded as a list of row dicts, one dict per row:
109
-
110
- ```markdown
111
- {% for person in people %}
112
- - {{ person.name }} ({{ person.role }})
113
- {% endfor %}
114
- ```
115
-
116
- Cell values containing `;` are automatically split into a list:
117
-
118
- ```csv
119
- name,skills
120
- Alice,python;flask;sql
121
- Bob,java
122
- ```
123
-
124
- ```markdown
125
- {{ people[0].skills }} {# → ["python", "flask", "sql"] #}
126
- {{ people[1].skills }} {# → "java" (plain string — no ;) #}
127
- ```
128
-
129
- Quoting a field in the CSV prevents `;` splitting — `"python;flask"` remains a single string.
130
-
131
- ### Excluding files
132
-
133
- Files whose name starts with `_` are excluded from scanning. Use this for Jinja2 macro files that should be imported but not rendered as documents:
134
-
135
- ```
136
- docs/
137
- _macros.j2 ← excluded; safe to use with {% import %}
138
- 01_intro.md
139
- 02_report.md.j2
140
- ```
141
-
142
- ### Using macros
143
-
144
- Use `{% import %}` or `{% from ... import %}` to make macros from another file callable — **not** `{% include %}`. `{% include %}` injects rendered output only; macros defined in an included file are not visible to the calling template and will raise an `undefined` error.
145
-
146
- ```jinja
147
- {# correct — macro is callable after this #}
148
- {% import "_macros.j2" as macros %}
149
- {{ macros.val(item) }}
150
-
151
- {# also correct #}
152
- {% from "_macros.j2" import val %}
153
- {{ val(item) }}
154
-
155
- {# wrong — val will be undefined #}
156
- {% include "_macros.j2" %}
157
- {{ val(item) }}
158
- ```
159
-
160
- ## Themes
161
-
162
- Themes are self-contained Jinja2 HTML files with embedded CSS. Pass a theme name with `--theme NAME`.
163
-
164
- | Theme | Description |
165
- |---|---|
166
- | `default` | Clean GitHub-style layout, 860 px centred column |
167
- | `default-wide` | Same as `default` but full viewport width |
168
- | `professional` | Corporate blue palette, dark title banner, card layout, 900 px centred |
169
- | `professional-wide` | Same as `professional` but full viewport width |
170
- | `dark` | Dark background, blue accent, light text — good for technical docs, 860 px centred |
171
- | `dark-wide` | Same as `dark` but full viewport width |
172
- | `academic` | Serif (Georgia) typography, justified text, print-optimised, 720 px centred |
173
- | `academic-wide` | Same as `academic` but full viewport width |
174
- | `vanilla` | Minimal HTML with no styling — useful for testing or custom CSS |
175
- | `paged-professional` | Corporate style with Paged.js pagination for print-ready PDFs |
176
-
177
- All themes support:
178
-
179
- - Optional document title
180
- - Optional table of contents
181
- - [Mermaid.js](https://mermaid.js.org) diagram support (loaded only when diagrams are present)
182
- - Graph diagram blocks
183
-
184
- ### Graph diagrams
185
-
186
- Use ` ```graph ` fenced blocks with a JSON payload. The only required field is `data`.
187
-
188
- **Minimal example** — all defaults applied:
189
-
190
- ````markdown
191
- ```graph
192
- {
193
- "data": {
194
- "x": ["Jan", "Feb", "Mar"],
195
- "Sales": [100, 150, 120]
196
- }
197
- }
198
- ```
199
- ````
200
-
201
- Series are inferred from the data keys (everything except `x`). Each series defaults to a line chart in blue.
202
-
203
- **Full schema:**
204
-
205
- | Field | Required | Default | Description |
206
- |---|---|---|---|
207
- | `data.x` | yes | — | Category labels |
208
- | `data.<name>` | yes | — | Values for each series (one key per series) |
209
- | `title` | no | _(none)_ | Chart title |
210
- | `orientation` | no | `vertical` | `vertical` or `horizontal` |
211
- | `show_legend` | no | `true` | Show the legend |
212
- | `width_px` | no | `640` | Width in pixels |
213
- | `height_px` | no | `480` | Height in pixels |
214
- | `min` / `max` | no | — | Axis bounds |
215
- | `series` | no | _(auto)_ | Override series definitions (see below) |
216
-
217
- **Series fields** (all optional when auto-generated):
218
-
219
- | Field | Default | Description |
220
- |---|---|---|
221
- | `label` | _(data key)_ | Must match a key in `data` |
222
- | `type` | `line` | `bar`, `line` (solid), or `line2` (dotted) |
223
- | `colour` | _(palette)_ | Colour string, or list of colours per bar |
224
- | `marker` | `false` | Show point markers (line types only) |
225
-
226
- **Full example:**
227
-
228
- ````markdown
229
- ```graph
230
- {
231
- "title": "Sales vs Target",
232
- "orientation": "vertical",
233
- "show_legend": true,
234
- "data": {
235
- "x": ["Jan", "Feb", "Mar", "Apr", "May"],
236
- "Sales": [85, 92, 78, 96, 110],
237
- "Target": [90, 90, 90, 90, 90]
238
- },
239
- "series": [
240
- { "label": "Sales", "type": "bar", "colour": "#3498db" },
241
- { "label": "Target", "type": "line", "colour": "#e74c3c", "marker": false }
242
- ]
243
- }
244
- ```
245
- ````
246
-
247
- ### Mermaid diagrams
248
-
249
- Use standard fenced code blocks in your markdown:
250
-
251
- ````markdown
252
- ```mermaid
253
- graph TD
254
- A[Start] --> B[End]
255
- ```
256
- ````
257
-
258
- mddoco detects mermaid blocks automatically and loads the Mermaid.js CDN only when needed.
1
+ # mddoco
2
+
3
+ A CLI tool that converts markdown files to a single HTML (or future PDF) document.
4
+
5
+ [![Publish to PyPI](https://github.com/massyn/mddoco/actions/workflows/ci.yml/badge.svg)](https://github.com/massyn/mddoco/actions/workflows/ci.yml)
6
+ ![PyPI Version](https://img.shields.io/pypi/v/mddoco) ![PyPI Downloads](https://img.shields.io/pypi/dd/mddoco)
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install mddoco
11
+ ```
12
+
13
+ Or for development:
14
+
15
+ ```bash
16
+ pip install -e .
17
+ ```
18
+
19
+ > **Playwright (Chromium) is required for PDF output only.** HTML output works without it.
20
+ > The `playwright` Python package is installed automatically, but the Chromium
21
+ > browser it drives is not. The first time you render a PDF, mddoco downloads
22
+ > Chromium for you (~150 MB, one time). To do it ahead of time, or if the
23
+ > automatic download fails, run it yourself:
24
+ >
25
+ > ```bash
26
+ > playwright install chromium
27
+ > ```
28
+
29
+ ## Usage
30
+
31
+ ```
32
+ mddoco [OPTIONS] INPUT_PATH
33
+ ```
34
+
35
+ `INPUT_PATH` can be a **directory** (all `*.md` and `*.md.j2` files are found recursively and sorted together) or a **single `.md` or `.md.j2` file**.
36
+
37
+ ### Options
38
+
39
+ | Option | Short | Default | Description |
40
+ |---|---|---|---|
41
+ | `--output PATH` | `-o` | `.` | Directory to write the output file |
42
+ | `--format [html\|pdf]` | `-f` | `html` | Output format |
43
+ | `--title TEXT` | `-t` | _(none)_ | Document title shown at the top of the page |
44
+ | `--theme NAME` | | `default` | Theme to use for rendering |
45
+ | `--toc / --no-toc` | | off | Generate a table of contents |
46
+ | `--toc-depth N` | | `3` | Maximum heading depth included in the TOC (1–6) |
47
+
48
+ ### Examples
49
+
50
+ Convert all markdown files in a directory:
51
+
52
+ ```bash
53
+ mddoco ./docs
54
+ ```
55
+
56
+ Convert a single file:
57
+
58
+ ```bash
59
+ mddoco README.md
60
+ ```
61
+
62
+ With a title, TOC, and custom output directory:
63
+
64
+ ```bash
65
+ mddoco ./docs --title "My Project" --toc --output ./out
66
+ ```
67
+
68
+ ## Output
69
+
70
+ All matched markdown files are combined into a single HTML document in the output directory. The filename is derived from the input folder or file name.
71
+
72
+ ## Examples
73
+
74
+ The [`examples/`](examples/) directory contains five runnable input folders, each
75
+ covering a different feature:
76
+
77
+ | Folder | Demonstrates |
78
+ |--------|--------------|
79
+ | [`examples/01_basic`](examples/01_basic) | Plain Markdown, file ordering, underscore-excluded files |
80
+ | [`examples/02_rich_content`](examples/02_rich_content) | Mermaid diagrams, syntax highlighting, `graph` charts |
81
+ | [`examples/03_themed_report`](examples/03_themed_report) | Themes and a table of contents |
82
+ | [`examples/04_jinja_data`](examples/04_jinja_data) | Jinja2 templates with JSON and CSV data files |
83
+ | [`examples/05_security_findings`](examples/05_security_findings) | CSV data grouped in a Jinja2 template and fed into a `graph` chart |
84
+
85
+ ```bash
86
+ mddoco examples/03_themed_report --theme professional --title "Q3 Platform Review" --toc --output ./out
87
+ ```
88
+
89
+ See [`examples/README.md`](examples/README.md) for the full list of commands.
90
+
91
+ ## Jinja2 templates
92
+
93
+ Files ending in `.md.j2` are Jinja2 templates that produce Markdown. They are sorted alongside regular `.md` files (numeric prefixes such as `01_`, `02_` determine order) and converted through the same pipeline.
94
+
95
+ ### Context variables (JSON and CSV)
96
+
97
+ Place `*.json` or `*.csv` files in the same input directory. Each file's stem becomes a top-level variable in the Jinja2 context — `report.json` is available as `report`, `people.csv` as `people`, and so on. If both `data.json` and `data.csv` exist, the tool will exit with an error.
98
+
99
+ ```
100
+ docs/
101
+ 01_intro.md
102
+ 02_summary.md.j2 ← Jinja2 template
103
+ report.json ← available as {{ report }}
104
+ people.csv ← available as {{ people }}
105
+ ```
106
+
107
+ **JSON** files are loaded as-is; the variable holds whatever structure the JSON contains.
108
+
109
+ **CSV** files are loaded as a list of row dicts, one dict per row:
110
+
111
+ ```markdown
112
+ {% for person in people %}
113
+ - {{ person.name }} ({{ person.role }})
114
+ {% endfor %}
115
+ ```
116
+
117
+ Cell values containing `;` are automatically split into a list:
118
+
119
+ ```csv
120
+ name,skills
121
+ Alice,python;flask;sql
122
+ Bob,java
123
+ ```
124
+
125
+ ```markdown
126
+ {{ people[0].skills }} {# → ["python", "flask", "sql"] #}
127
+ {{ people[1].skills }} {# → "java" (plain string — no ;) #}
128
+ ```
129
+
130
+ Quoting a field in the CSV prevents `;` splitting — `"python;flask"` remains a single string.
131
+
132
+ ### Excluding files
133
+
134
+ Files whose name starts with `_` are excluded from scanning. Use this for Jinja2 macro files that should be imported but not rendered as documents:
135
+
136
+ ```
137
+ docs/
138
+ _macros.j2 ← excluded; safe to use with {% import %}
139
+ 01_intro.md
140
+ 02_report.md.j2
141
+ ```
142
+
143
+ ### Using macros
144
+
145
+ Use `{% import %}` or `{% from ... import %}` to make macros from another file callable — **not** `{% include %}`. `{% include %}` injects rendered output only; macros defined in an included file are not visible to the calling template and will raise an `undefined` error.
146
+
147
+ ```jinja
148
+ {# correct — macro is callable after this #}
149
+ {% import "_macros.j2" as macros %}
150
+ {{ macros.val(item) }}
151
+
152
+ {# also correct #}
153
+ {% from "_macros.j2" import val %}
154
+ {{ val(item) }}
155
+
156
+ {# wrong — val will be undefined #}
157
+ {% include "_macros.j2" %}
158
+ {{ val(item) }}
159
+ ```
160
+
161
+ ## Themes
162
+
163
+ Themes are Jinja2 HTML files with embedded CSS. Pass a theme name with `--theme NAME`. The `-wide` and `site-*` themes extend another theme (`default.html`, `_site_base.html` and so on), so to customise one of those, copy the theme it extends as well.
164
+
165
+ | Theme | Description |
166
+ |---|---|
167
+ | `default` | Clean GitHub-style layout, 860 px centred column |
168
+ | `default-wide` | Same as `default` but full viewport width |
169
+ | `professional` | Corporate blue palette, dark title banner, card layout, 900 px centred |
170
+ | `professional-wide` | Same as `professional` but full viewport width |
171
+ | `dark` | Dark background, blue accent, light text — good for technical docs, 860 px centred |
172
+ | `dark-wide` | Same as `dark` but full viewport width |
173
+ | `academic` | Serif (Georgia) typography, justified text, print-optimised, 720 px centred |
174
+ | `academic-wide` | Same as `academic` but full viewport width |
175
+ | `vanilla` | Minimal HTML with no styling — useful for testing or custom CSS |
176
+ | `paged-professional` | Corporate style with Paged.js pagination for print-ready PDFs |
177
+ | `site` | Website layout: side nav with one page per H1, minimalist styling (HTML only) |
178
+ | `site-professional` | Same as `site` with a navy sidebar and card layout (HTML only) |
179
+ | `site-dark` | Same as `site` on a dark background (HTML only) |
180
+ | `site-terminal` | Same as `site` as a green-phosphor terminal, just for fun (HTML only) |
181
+
182
+ All themes support:
183
+
184
+ - Optional document title
185
+ - Optional table of contents (the `site-*` themes use their side nav instead)
186
+ - [Mermaid.js](https://mermaid.js.org) diagram support (loaded only when diagrams are present)
187
+ - Graph diagram blocks
188
+
189
+ ### Site themes
190
+
191
+ The `site-*` themes turn the output into a small website while keeping it a single HTML file: no web server needed, and it still works offline or as an email attachment.
192
+
193
+ ```bash
194
+ mddoco ./docs --theme site --title "Team Handbook" --output ./out
195
+ ```
196
+
197
+ - Every H1 starts a new page, and each page is listed in the side nav. Anything before the first H1 becomes an introduction page.
198
+ - The current page's H2 headings are listed under it in the nav.
199
+ - Only one page shows at a time, with previous/next links at the bottom. Each page has its own address (`handbook.html#/onboarding`, or `#/onboarding/first-week` for a heading), so the back button, bookmarks and shared links work.
200
+ - On narrow screens the nav moves behind a menu button.
201
+ - They are screen-only: `--format pdf` is refused. Printing from the browser still prints every page in sequence.
202
+
203
+ ### Screen-only custom themes
204
+
205
+ A custom theme can refuse PDF output by declaring this at the top level of its template:
206
+
207
+ ```jinja
208
+ {% set pdf_supported = false %}
209
+ ```
210
+
211
+ `--format pdf` with that theme then exits with an error instead of producing a PDF.
212
+
213
+ ### Graph diagrams
214
+
215
+ Use ` ```graph ` fenced blocks with a JSON payload. The only required field is `data`.
216
+
217
+ **Minimal example** — all defaults applied:
218
+
219
+ ````markdown
220
+ ```graph
221
+ {
222
+ "data": {
223
+ "x": ["Jan", "Feb", "Mar"],
224
+ "Sales": [100, 150, 120]
225
+ }
226
+ }
227
+ ```
228
+ ````
229
+
230
+ Series are inferred from the data keys (everything except `x`). Each series defaults to a line chart in blue.
231
+
232
+ **Full schema:**
233
+
234
+ | Field | Required | Default | Description |
235
+ |---|---|---|---|
236
+ | `data.x` | yes | — | Category labels |
237
+ | `data.<name>` | yes | — | Values for each series (one key per series) |
238
+ | `title` | no | _(none)_ | Chart title |
239
+ | `orientation` | no | `vertical` | `vertical` or `horizontal` |
240
+ | `show_legend` | no | `true` | Show the legend |
241
+ | `width_px` | no | `640` | Width in pixels |
242
+ | `height_px` | no | `480` | Height in pixels |
243
+ | `min` / `max` | no | — | Axis bounds |
244
+ | `series` | no | _(auto)_ | Override series definitions (see below) |
245
+
246
+ **Series fields** (all optional when auto-generated):
247
+
248
+ | Field | Default | Description |
249
+ |---|---|---|
250
+ | `label` | _(data key)_ | Must match a key in `data` |
251
+ | `type` | `line` | `bar`, `line` (solid), or `line2` (dotted) |
252
+ | `colour` | _(palette)_ | Colour string, or list of colours per bar |
253
+ | `marker` | `false` | Show point markers (line types only) |
254
+
255
+ **Full example:**
256
+
257
+ ````markdown
258
+ ```graph
259
+ {
260
+ "title": "Sales vs Target",
261
+ "orientation": "vertical",
262
+ "show_legend": true,
263
+ "data": {
264
+ "x": ["Jan", "Feb", "Mar", "Apr", "May"],
265
+ "Sales": [85, 92, 78, 96, 110],
266
+ "Target": [90, 90, 90, 90, 90]
267
+ },
268
+ "series": [
269
+ { "label": "Sales", "type": "bar", "colour": "#3498db" },
270
+ { "label": "Target", "type": "line", "colour": "#e74c3c", "marker": false }
271
+ ]
272
+ }
273
+ ```
274
+ ````
275
+
276
+ ### Mermaid diagrams
277
+
278
+ Use standard fenced code blocks in your markdown:
279
+
280
+ ````markdown
281
+ ```mermaid
282
+ graph TD
283
+ A[Start] --> B[End]
284
+ ```
285
+ ````
286
+
287
+ mddoco detects mermaid blocks automatically and loads the Mermaid.js CDN only when needed.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "mddoco"
7
- version = "2.1.0"
7
+ version = "2.2.0"
8
8
  description = "Markdown to HTML/PDF document converter"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -0,0 +1 @@
1
+ __version__ = "2.2.0"