mdformat-zola 1.0.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.
- mdformat_zola-1.0.0/.github/FUNDING.yaml +2 -0
- mdformat_zola-1.0.0/.github/SECURITY.md +9 -0
- mdformat_zola-1.0.0/.github/dependabot.yaml +8 -0
- mdformat_zola-1.0.0/.github/release.yaml +5 -0
- mdformat_zola-1.0.0/.github/workflows/check.yaml +80 -0
- mdformat_zola-1.0.0/.github/workflows/release.yaml +48 -0
- mdformat_zola-1.0.0/.gitignore +10 -0
- mdformat_zola-1.0.0/.pre-commit-config.yaml +57 -0
- mdformat_zola-1.0.0/CONTRIBUTING.md +71 -0
- mdformat_zola-1.0.0/LICENSE +21 -0
- mdformat_zola-1.0.0/PKG-INFO +181 -0
- mdformat_zola-1.0.0/README.md +121 -0
- mdformat_zola-1.0.0/pyproject.toml +153 -0
- mdformat_zola-1.0.0/src/mdformat_zola/__init__.py +18 -0
- mdformat_zola-1.0.0/src/mdformat_zola/_mdit_plugins/__init__.py +3 -0
- mdformat_zola-1.0.0/src/mdformat_zola/_mdit_plugins/shortcodes.py +153 -0
- mdformat_zola-1.0.0/src/mdformat_zola/_plugin.py +51 -0
- mdformat_zola-1.0.0/src/mdformat_zola/_renderer.py +117 -0
- mdformat_zola-1.0.0/src/mdformat_zola/_syntax.py +221 -0
- mdformat_zola-1.0.0/src/mdformat_zola/py.typed +0 -0
- mdformat_zola-1.0.0/tests/conftest.py +30 -0
- mdformat_zola-1.0.0/tests/fixtures/kitchen_sink.md +53 -0
- mdformat_zola-1.0.0/tests/test_features.py +223 -0
- mdformat_zola-1.0.0/tests/test_fence.py +108 -0
- mdformat_zola-1.0.0/tests/test_headings.py +48 -0
- mdformat_zola-1.0.0/tests/test_integration.py +75 -0
- mdformat_zola-1.0.0/tests/test_markdown_body.py +85 -0
- mdformat_zola-1.0.0/tests/test_real_world.py +37 -0
- mdformat_zola-1.0.0/tests/test_shortcodes_block.py +135 -0
- mdformat_zola-1.0.0/tests/test_shortcodes_inline.py +76 -0
- mdformat_zola-1.0.0/tests/test_syntax.py +104 -0
- mdformat_zola-1.0.0/tox.toml +94 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
Only the latest released version is supported with security updates. Older versions will not receive patches.
|
|
6
|
+
|
|
7
|
+
## Reporting a Vulnerability
|
|
8
|
+
|
|
9
|
+
Please report security vulnerabilities via [GitHub's private vulnerability reporting](../../security/advisories/new).
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
name: ๐งช check
|
|
2
|
+
on:
|
|
3
|
+
workflow_dispatch:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["main"]
|
|
6
|
+
pull_request:
|
|
7
|
+
schedule:
|
|
8
|
+
- cron: "0 8 * * *"
|
|
9
|
+
concurrency:
|
|
10
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
jobs:
|
|
15
|
+
test:
|
|
16
|
+
name: ๐งช test ${{ matrix.py }} - ${{ matrix.os }}
|
|
17
|
+
if: github.event_name != 'schedule' || github.repository_owner == 'gaborbernat'
|
|
18
|
+
runs-on: ${{ matrix.os }}
|
|
19
|
+
timeout-minutes: 40
|
|
20
|
+
strategy:
|
|
21
|
+
fail-fast: false
|
|
22
|
+
matrix:
|
|
23
|
+
py:
|
|
24
|
+
- "3.14"
|
|
25
|
+
- "3.13"
|
|
26
|
+
- "3.12"
|
|
27
|
+
- "3.11"
|
|
28
|
+
os:
|
|
29
|
+
- ubuntu-24.04
|
|
30
|
+
- macos-15
|
|
31
|
+
- windows-2025
|
|
32
|
+
steps:
|
|
33
|
+
- name: ๐ Install uv
|
|
34
|
+
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
|
|
35
|
+
- name: ๐ฅ Checkout code
|
|
36
|
+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
37
|
+
with:
|
|
38
|
+
fetch-depth: 0
|
|
39
|
+
persist-credentials: false
|
|
40
|
+
- name: ๐ฆ Install tox with tox-uv
|
|
41
|
+
run: uv tool install --managed-python --python 3.14 tox --with tox-uv
|
|
42
|
+
- name: ๐ Setup Python for test ${{ matrix.py }}
|
|
43
|
+
run: uv python install ${{ matrix.py }}
|
|
44
|
+
- name: ๐๏ธ Setup test suite
|
|
45
|
+
run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.py }}
|
|
46
|
+
- name: ๐ Run test suite
|
|
47
|
+
run: tox run --skip-pkg-install -e ${{ matrix.py }}
|
|
48
|
+
timeout-minutes: 20
|
|
49
|
+
env:
|
|
50
|
+
PYTEST_ADDOPTS: "-vv --durations=20"
|
|
51
|
+
CI_RUN: "yes"
|
|
52
|
+
DIFF_AGAINST: HEAD
|
|
53
|
+
check:
|
|
54
|
+
name: ๐ check ${{ matrix.tox_env }} - ${{ matrix.os }}
|
|
55
|
+
if: github.event_name != 'schedule' || github.repository_owner == 'gaborbernat'
|
|
56
|
+
runs-on: ${{ matrix.os }}
|
|
57
|
+
strategy:
|
|
58
|
+
fail-fast: false
|
|
59
|
+
matrix:
|
|
60
|
+
tox_env:
|
|
61
|
+
- dev
|
|
62
|
+
- type
|
|
63
|
+
- pkg_meta
|
|
64
|
+
os:
|
|
65
|
+
- ubuntu-24.04
|
|
66
|
+
- windows-2025
|
|
67
|
+
steps:
|
|
68
|
+
- name: ๐ Install uv
|
|
69
|
+
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
|
|
70
|
+
- name: ๐ฆ Install tox
|
|
71
|
+
run: uv tool install --python-preference only-managed --python 3.14 tox --with tox-uv
|
|
72
|
+
- name: ๐ฅ Checkout code
|
|
73
|
+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
74
|
+
with:
|
|
75
|
+
fetch-depth: 0
|
|
76
|
+
persist-credentials: false
|
|
77
|
+
- name: ๐๏ธ Setup check suite
|
|
78
|
+
run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.tox_env }}
|
|
79
|
+
- name: ๐ Run check for ${{ matrix.tox_env }}
|
|
80
|
+
run: tox run --skip-pkg-install -e ${{ matrix.tox_env }}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
name: Release to PyPI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
tags: ["*"]
|
|
5
|
+
permissions:
|
|
6
|
+
contents: read
|
|
7
|
+
env:
|
|
8
|
+
dists-artifact-name: python-package-distributions
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- name: ๐ฅ Checkout code
|
|
14
|
+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
15
|
+
with:
|
|
16
|
+
fetch-depth: 0
|
|
17
|
+
persist-credentials: false
|
|
18
|
+
- name: ๐ Install the latest version of uv
|
|
19
|
+
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
|
|
20
|
+
with:
|
|
21
|
+
cache-dependency-glob: "pyproject.toml"
|
|
22
|
+
enable-cache: false
|
|
23
|
+
- name: ๐ฆ Build package
|
|
24
|
+
run: uv build --python 3.14 --python-preference only-managed --sdist --wheel . --out-dir dist
|
|
25
|
+
- name: ๐ค Store the distribution packages
|
|
26
|
+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
|
27
|
+
with:
|
|
28
|
+
name: ${{ env.dists-artifact-name }}
|
|
29
|
+
path: dist/*
|
|
30
|
+
release:
|
|
31
|
+
needs:
|
|
32
|
+
- build
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
environment:
|
|
35
|
+
name: release
|
|
36
|
+
url: https://pypi.org/project/mdformat-zola/${{ github.ref_name }}
|
|
37
|
+
permissions:
|
|
38
|
+
id-token: write
|
|
39
|
+
steps:
|
|
40
|
+
- name: ๐ฅ Download all the dists
|
|
41
|
+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
|
|
42
|
+
with:
|
|
43
|
+
name: ${{ env.dists-artifact-name }}
|
|
44
|
+
path: dist/
|
|
45
|
+
- name: ๐ Publish to PyPI
|
|
46
|
+
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
|
|
47
|
+
with:
|
|
48
|
+
attestations: true
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: v6.0.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: end-of-file-fixer
|
|
6
|
+
- id: trailing-whitespace
|
|
7
|
+
- id: file-contents-sorter
|
|
8
|
+
files: "^.gitignore$"
|
|
9
|
+
- id: check-case-conflict
|
|
10
|
+
- id: check-added-large-files
|
|
11
|
+
- repo: https://github.com/rhysd/actionlint
|
|
12
|
+
rev: "v1.7.10"
|
|
13
|
+
hooks:
|
|
14
|
+
- id: actionlint
|
|
15
|
+
- repo: https://github.com/codespell-project/codespell
|
|
16
|
+
rev: v2.4.1
|
|
17
|
+
hooks:
|
|
18
|
+
- id: codespell
|
|
19
|
+
additional_dependencies: ["tomli>=2.4.1; python_version < '3.11'"]
|
|
20
|
+
- repo: https://github.com/tox-dev/tox-toml-fmt
|
|
21
|
+
rev: "v1.6.0"
|
|
22
|
+
hooks:
|
|
23
|
+
- id: tox-toml-fmt
|
|
24
|
+
- repo: https://github.com/tox-dev/pyproject-fmt
|
|
25
|
+
rev: "v2.16.0"
|
|
26
|
+
hooks:
|
|
27
|
+
- id: pyproject-fmt
|
|
28
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
29
|
+
rev: "v0.15.1"
|
|
30
|
+
hooks:
|
|
31
|
+
- id: ruff-format
|
|
32
|
+
- id: ruff-check
|
|
33
|
+
args: ["--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"]
|
|
34
|
+
- repo: https://github.com/google/yamlfmt
|
|
35
|
+
rev: "v0.21.0"
|
|
36
|
+
hooks:
|
|
37
|
+
- id: yamlfmt
|
|
38
|
+
- repo: https://github.com/hukkin/mdformat
|
|
39
|
+
rev: "1.0.0"
|
|
40
|
+
hooks:
|
|
41
|
+
- id: mdformat
|
|
42
|
+
args: ["--wrap=120"]
|
|
43
|
+
additional_dependencies:
|
|
44
|
+
- mdformat-gfm>=1
|
|
45
|
+
- mdformat-gfm-alerts>=2
|
|
46
|
+
- mdformat-footnote>=0.1.3
|
|
47
|
+
- mdformat-front-matters>=2
|
|
48
|
+
- mdformat-deflist>=0.1.4
|
|
49
|
+
exclude: "^tests/fixtures/"
|
|
50
|
+
- repo: https://github.com/zizmorcore/zizmor-pre-commit
|
|
51
|
+
rev: v1.23.1
|
|
52
|
+
hooks:
|
|
53
|
+
- id: zizmor
|
|
54
|
+
- repo: meta
|
|
55
|
+
hooks:
|
|
56
|
+
- id: check-hooks-apply
|
|
57
|
+
- id: check-useless-excludes
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Contributing to mdformat-zola
|
|
2
|
+
|
|
3
|
+
Contributions are welcome and appreciated.
|
|
4
|
+
|
|
5
|
+
## Development setup
|
|
6
|
+
|
|
7
|
+
Clone the repository and create the development environment:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
git clone https://github.com/gaborbernat/mdformat-zola.git
|
|
11
|
+
cd mdformat-zola
|
|
12
|
+
tox -e dev
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This creates a `.tox/dev` virtual environment with all dependencies installed in editable mode.
|
|
16
|
+
|
|
17
|
+
## Running the checks
|
|
18
|
+
|
|
19
|
+
Run the tests across the supported Python versions:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
tox -e 3.14,3.13,3.12,3.11
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Format and lint (ruff, via pre-commit):
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
tox -e fix
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Type check (ty):
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
tox -e type
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The project keeps 100% test coverage and passes ruff and ty on every change.
|
|
38
|
+
|
|
39
|
+
## How it works
|
|
40
|
+
|
|
41
|
+
- `_syntax.py` holds the pure, mdformat-independent formatting: it parses shortcode calls, heading attributes, and
|
|
42
|
+
code-fence annotations, and emits their canonical form. `tests/test_syntax.py` covers it in isolation.
|
|
43
|
+
- `_mdit_plugins/shortcodes.py` adds the markdown-it-py rules that turn shortcodes into tokens: an inline rule for
|
|
44
|
+
`{{ โฆ }}` and a block rule that captures `{% โฆ %} โฆ {% end %}` bodies.
|
|
45
|
+
- `_renderer.py` renders those tokens, formats prose-shortcode bodies as Markdown while leaving raw ones (Mermaid and
|
|
46
|
+
the like) verbatim, normalizes code-fence annotations, and post-processes heading attributes.
|
|
47
|
+
- `_plugin.py` wires everything to mdformat's parser-extension interface.
|
|
48
|
+
|
|
49
|
+
## Writing tests
|
|
50
|
+
|
|
51
|
+
Tests format Markdown through the public API and assert on the result:
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from __future__ import annotations
|
|
55
|
+
|
|
56
|
+
import mdformat
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_example() -> None:
|
|
60
|
+
assert mdformat.text('{{ youtube( id="x" ) }}\n', extensions=["zola"]) == '{{ youtube(id="x") }}\n'
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Each test checks one behavior; parametrize near-duplicates. Drive the plugin through `mdformat.text`, and cover the pure
|
|
64
|
+
helpers in `_syntax.py` through their own tests.
|
|
65
|
+
|
|
66
|
+
## Pull requests
|
|
67
|
+
|
|
68
|
+
1. Branch from `main`.
|
|
69
|
+
1. Make the change with tests.
|
|
70
|
+
1. Run `tox -e fix`, `tox -e type`, and the test environments.
|
|
71
|
+
1. Commit following the Commitizen convention and open a pull request.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bernรกt Gรกbor
|
|
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.
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mdformat-zola
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Mdformat plugin for Zola-flavored Markdown
|
|
5
|
+
Project-URL: Documentation, https://github.com/gaborbernat/mdformat-zola
|
|
6
|
+
Project-URL: Homepage, https://github.com/gaborbernat/mdformat-zola
|
|
7
|
+
Project-URL: Source, https://github.com/gaborbernat/mdformat-zola
|
|
8
|
+
Project-URL: Tracker, https://github.com/gaborbernat/mdformat-zola/issues
|
|
9
|
+
Maintainer-email: Bernรกt Gรกbor <gaborjbernat@gmail.com>
|
|
10
|
+
License: MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2026 Bernรกt Gรกbor
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Keywords: formatter,markdown,mdformat,zola
|
|
33
|
+
Classifier: Development Status :: 4 - Beta
|
|
34
|
+
Classifier: Intended Audience :: Developers
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Operating System :: OS Independent
|
|
37
|
+
Classifier: Programming Language :: Python
|
|
38
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
43
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
44
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
45
|
+
Requires-Python: >=3.11
|
|
46
|
+
Requires-Dist: markdown-it-py>=4.2
|
|
47
|
+
Requires-Dist: mdformat-config>=0.2.1
|
|
48
|
+
Requires-Dist: mdformat-deflist>=0.1.4
|
|
49
|
+
Requires-Dist: mdformat-footnote>=0.1.3
|
|
50
|
+
Requires-Dist: mdformat-front-matters>=2
|
|
51
|
+
Requires-Dist: mdformat-gfm-alerts>=2
|
|
52
|
+
Requires-Dist: mdformat-gfm>=1
|
|
53
|
+
Requires-Dist: mdformat-pyproject>=0.1.1
|
|
54
|
+
Requires-Dist: mdformat-ruff>=0.1.3
|
|
55
|
+
Requires-Dist: mdformat-shfmt>=0.2
|
|
56
|
+
Requires-Dist: mdformat-web>=0.2
|
|
57
|
+
Requires-Dist: mdformat>=1
|
|
58
|
+
Requires-Dist: mdit-py-plugins>=0.6.1
|
|
59
|
+
Description-Content-Type: text/markdown
|
|
60
|
+
|
|
61
|
+
# mdformat-zola
|
|
62
|
+
|
|
63
|
+
[](https://pypi.org/project/mdformat-zola/)
|
|
64
|
+
[](https://pypi.org/project/mdformat-zola/)
|
|
65
|
+
[](https://github.com/gaborbernat/mdformat-zola/actions/workflows/check.yaml)
|
|
66
|
+
|
|
67
|
+
Mdformat plugin for [Zola](https://www.getzola.org)-flavored Markdown. It formats Zola content files while keeping
|
|
68
|
+
shortcodes, heading anchors, and code-block annotations intact.
|
|
69
|
+
|
|
70
|
+
Plain mdformat mangles Zola content. It reflows shortcode bodies (a Mermaid diagram becomes one escaped line), escapes
|
|
71
|
+
the `*` in `{{/* โฆ */}}`, and wraps long inline shortcodes mid-call. This plugin adds Zola's syntax to mdformat so those
|
|
72
|
+
constructs round-trip.
|
|
73
|
+
|
|
74
|
+
## Zola syntax
|
|
75
|
+
|
|
76
|
+
Each construct below gets one stable form. Where Zola treats ordering as insignificant, the plugin sorts.
|
|
77
|
+
|
|
78
|
+
### Shortcodes
|
|
79
|
+
|
|
80
|
+
The plugin normalizes inline shortcodes `{{ name(args) }}` and their escaped form `{{/* name(args) */}}`: it collapses
|
|
81
|
+
whitespace, sorts arguments by name, and settles on one quote style. It does not wrap or escape them.
|
|
82
|
+
|
|
83
|
+
**Input:**
|
|
84
|
+
|
|
85
|
+
```markdown
|
|
86
|
+
{{ youtube( autoplay=true , id="dQw4w9WgXcQ" ) }}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Output:**
|
|
90
|
+
|
|
91
|
+
```markdown
|
|
92
|
+
{{ youtube(autoplay=true, id="dQw4w9WgXcQ") }}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Body shortcodes `{% name(args) %} โฆ {% end %}` (and the escaped `{%/* โฆ */%}`) get the same treatment on their opening
|
|
96
|
+
tag. A raw body such as a Mermaid diagram stays byte-for-byte:
|
|
97
|
+
|
|
98
|
+
```markdown
|
|
99
|
+
{% mermaid() %}
|
|
100
|
+
graph TD
|
|
101
|
+
A["velodex[x]"] --> B[*]
|
|
102
|
+
{% end %}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The body of a prose shortcode is Markdown that Zola re-renders, so the plugin formats it. By default this applies to
|
|
106
|
+
`admonition`, `aside`, `callout`, `caution`, `details`, `important`, `note`, `quote`, `tip`, and `warning`; every other
|
|
107
|
+
shortcode keeps its body verbatim. Point the plugin at your own set with the `markdown_shortcodes` option, on the CLI or
|
|
108
|
+
in `.mdformat.toml`:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
mdformat --zola-markdown-shortcodes quote,note,sidebar content/
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
```toml
|
|
115
|
+
# .mdformat.toml
|
|
116
|
+
[plugin.zola]
|
|
117
|
+
markdown_shortcodes = ["quote", "note", "sidebar"]
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Pass an empty value to keep every body verbatim.
|
|
121
|
+
|
|
122
|
+
### Heading anchors
|
|
123
|
+
|
|
124
|
+
Zola lets you pin a heading's [id and classes](https://www.getzola.org/documentation/content/linking/) with a
|
|
125
|
+
`{#id .class}` suffix. The plugin puts the id first, then the classes in alphabetical order:
|
|
126
|
+
|
|
127
|
+
```markdown
|
|
128
|
+
## Introduction {.lead #intro}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Formats to:
|
|
132
|
+
|
|
133
|
+
```markdown
|
|
134
|
+
## Introduction {#intro .lead}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Code-block annotations
|
|
138
|
+
|
|
139
|
+
The plugin reorders Zola's
|
|
140
|
+
[syntax-highlighting annotations](https://www.getzola.org/documentation/content/syntax-highlighting/) to a fixed
|
|
141
|
+
sequence (`linenos`, `linenostart`, `hl_lines`, `hide_lines`, `name`), normalizes their whitespace, and keeps unknown
|
|
142
|
+
annotations:
|
|
143
|
+
|
|
144
|
+
````markdown
|
|
145
|
+
```rust, hl_lines=3-4 8-9,linenos , linenostart=10
|
|
146
|
+
````
|
|
147
|
+
|
|
148
|
+
Formats to:
|
|
149
|
+
|
|
150
|
+
````markdown
|
|
151
|
+
```rust,linenos,linenostart=10,hl_lines=3-4 8-9
|
|
152
|
+
````
|
|
153
|
+
|
|
154
|
+
Internal links such as `[text](@/pages/about.md#anchor)` survive as ordinary links, no special handling needed.
|
|
155
|
+
|
|
156
|
+
## Bundled features
|
|
157
|
+
|
|
158
|
+
Installing the plugin pulls in the mdformat plugins that cover the rest of Zola's Markdown flavor (GitHub-Flavored
|
|
159
|
+
Markdown with footnotes, definition lists, alerts, and TOML `+++` frontmatter), plus code formatters for fenced blocks:
|
|
160
|
+
|
|
161
|
+
**Markdown syntax:**
|
|
162
|
+
|
|
163
|
+
- [mdformat-gfm](https://github.com/hukkin/mdformat-gfm) - tables, strikethrough, task lists, autolinks
|
|
164
|
+
- [mdformat-front-matters](https://github.com/kyleking/mdformat-front-matters) - TOML/YAML/JSON frontmatter
|
|
165
|
+
- [mdformat-gfm-alerts](https://github.com/KyleKing/mdformat-gfm-alerts) - blockquote alerts (`[!NOTE]`, `[!WARNING]`)
|
|
166
|
+
- [mdformat-footnote](https://github.com/executablebooks/mdformat-footnote) - footnotes
|
|
167
|
+
- [mdformat-deflist](https://github.com/executablebooks/mdformat-deflist) - definition lists
|
|
168
|
+
|
|
169
|
+
**Code-block formatting:**
|
|
170
|
+
|
|
171
|
+
- [mdformat-ruff](https://github.com/Freed-Wu/mdformat-ruff) - Python blocks with ruff
|
|
172
|
+
- [mdformat-shfmt](https://github.com/hukkin/mdformat-shfmt) - shell blocks with shfmt
|
|
173
|
+
- [mdformat-config](https://github.com/hukkin/mdformat-config) - JSON, YAML, TOML blocks
|
|
174
|
+
- [mdformat-web](https://github.com/hukkin/mdformat-web) - HTML, CSS, JavaScript blocks
|
|
175
|
+
- [mdformat-pyproject](https://github.com/csala/mdformat-pyproject) - pyproject.toml blocks
|
|
176
|
+
|
|
177
|
+
## Usage
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
mdformat content/
|
|
181
|
+
```
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# mdformat-zola
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/mdformat-zola/)
|
|
4
|
+
[](https://pypi.org/project/mdformat-zola/)
|
|
5
|
+
[](https://github.com/gaborbernat/mdformat-zola/actions/workflows/check.yaml)
|
|
6
|
+
|
|
7
|
+
Mdformat plugin for [Zola](https://www.getzola.org)-flavored Markdown. It formats Zola content files while keeping
|
|
8
|
+
shortcodes, heading anchors, and code-block annotations intact.
|
|
9
|
+
|
|
10
|
+
Plain mdformat mangles Zola content. It reflows shortcode bodies (a Mermaid diagram becomes one escaped line), escapes
|
|
11
|
+
the `*` in `{{/* โฆ */}}`, and wraps long inline shortcodes mid-call. This plugin adds Zola's syntax to mdformat so those
|
|
12
|
+
constructs round-trip.
|
|
13
|
+
|
|
14
|
+
## Zola syntax
|
|
15
|
+
|
|
16
|
+
Each construct below gets one stable form. Where Zola treats ordering as insignificant, the plugin sorts.
|
|
17
|
+
|
|
18
|
+
### Shortcodes
|
|
19
|
+
|
|
20
|
+
The plugin normalizes inline shortcodes `{{ name(args) }}` and their escaped form `{{/* name(args) */}}`: it collapses
|
|
21
|
+
whitespace, sorts arguments by name, and settles on one quote style. It does not wrap or escape them.
|
|
22
|
+
|
|
23
|
+
**Input:**
|
|
24
|
+
|
|
25
|
+
```markdown
|
|
26
|
+
{{ youtube( autoplay=true , id="dQw4w9WgXcQ" ) }}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Output:**
|
|
30
|
+
|
|
31
|
+
```markdown
|
|
32
|
+
{{ youtube(autoplay=true, id="dQw4w9WgXcQ") }}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Body shortcodes `{% name(args) %} โฆ {% end %}` (and the escaped `{%/* โฆ */%}`) get the same treatment on their opening
|
|
36
|
+
tag. A raw body such as a Mermaid diagram stays byte-for-byte:
|
|
37
|
+
|
|
38
|
+
```markdown
|
|
39
|
+
{% mermaid() %}
|
|
40
|
+
graph TD
|
|
41
|
+
A["velodex[x]"] --> B[*]
|
|
42
|
+
{% end %}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The body of a prose shortcode is Markdown that Zola re-renders, so the plugin formats it. By default this applies to
|
|
46
|
+
`admonition`, `aside`, `callout`, `caution`, `details`, `important`, `note`, `quote`, `tip`, and `warning`; every other
|
|
47
|
+
shortcode keeps its body verbatim. Point the plugin at your own set with the `markdown_shortcodes` option, on the CLI or
|
|
48
|
+
in `.mdformat.toml`:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
mdformat --zola-markdown-shortcodes quote,note,sidebar content/
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```toml
|
|
55
|
+
# .mdformat.toml
|
|
56
|
+
[plugin.zola]
|
|
57
|
+
markdown_shortcodes = ["quote", "note", "sidebar"]
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Pass an empty value to keep every body verbatim.
|
|
61
|
+
|
|
62
|
+
### Heading anchors
|
|
63
|
+
|
|
64
|
+
Zola lets you pin a heading's [id and classes](https://www.getzola.org/documentation/content/linking/) with a
|
|
65
|
+
`{#id .class}` suffix. The plugin puts the id first, then the classes in alphabetical order:
|
|
66
|
+
|
|
67
|
+
```markdown
|
|
68
|
+
## Introduction {.lead #intro}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Formats to:
|
|
72
|
+
|
|
73
|
+
```markdown
|
|
74
|
+
## Introduction {#intro .lead}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Code-block annotations
|
|
78
|
+
|
|
79
|
+
The plugin reorders Zola's
|
|
80
|
+
[syntax-highlighting annotations](https://www.getzola.org/documentation/content/syntax-highlighting/) to a fixed
|
|
81
|
+
sequence (`linenos`, `linenostart`, `hl_lines`, `hide_lines`, `name`), normalizes their whitespace, and keeps unknown
|
|
82
|
+
annotations:
|
|
83
|
+
|
|
84
|
+
````markdown
|
|
85
|
+
```rust, hl_lines=3-4 8-9,linenos , linenostart=10
|
|
86
|
+
````
|
|
87
|
+
|
|
88
|
+
Formats to:
|
|
89
|
+
|
|
90
|
+
````markdown
|
|
91
|
+
```rust,linenos,linenostart=10,hl_lines=3-4 8-9
|
|
92
|
+
````
|
|
93
|
+
|
|
94
|
+
Internal links such as `[text](@/pages/about.md#anchor)` survive as ordinary links, no special handling needed.
|
|
95
|
+
|
|
96
|
+
## Bundled features
|
|
97
|
+
|
|
98
|
+
Installing the plugin pulls in the mdformat plugins that cover the rest of Zola's Markdown flavor (GitHub-Flavored
|
|
99
|
+
Markdown with footnotes, definition lists, alerts, and TOML `+++` frontmatter), plus code formatters for fenced blocks:
|
|
100
|
+
|
|
101
|
+
**Markdown syntax:**
|
|
102
|
+
|
|
103
|
+
- [mdformat-gfm](https://github.com/hukkin/mdformat-gfm) - tables, strikethrough, task lists, autolinks
|
|
104
|
+
- [mdformat-front-matters](https://github.com/kyleking/mdformat-front-matters) - TOML/YAML/JSON frontmatter
|
|
105
|
+
- [mdformat-gfm-alerts](https://github.com/KyleKing/mdformat-gfm-alerts) - blockquote alerts (`[!NOTE]`, `[!WARNING]`)
|
|
106
|
+
- [mdformat-footnote](https://github.com/executablebooks/mdformat-footnote) - footnotes
|
|
107
|
+
- [mdformat-deflist](https://github.com/executablebooks/mdformat-deflist) - definition lists
|
|
108
|
+
|
|
109
|
+
**Code-block formatting:**
|
|
110
|
+
|
|
111
|
+
- [mdformat-ruff](https://github.com/Freed-Wu/mdformat-ruff) - Python blocks with ruff
|
|
112
|
+
- [mdformat-shfmt](https://github.com/hukkin/mdformat-shfmt) - shell blocks with shfmt
|
|
113
|
+
- [mdformat-config](https://github.com/hukkin/mdformat-config) - JSON, YAML, TOML blocks
|
|
114
|
+
- [mdformat-web](https://github.com/hukkin/mdformat-web) - HTML, CSS, JavaScript blocks
|
|
115
|
+
- [mdformat-pyproject](https://github.com/csala/mdformat-pyproject) - pyproject.toml blocks
|
|
116
|
+
|
|
117
|
+
## Usage
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
mdformat content/
|
|
121
|
+
```
|