# mdformat-mkdocs
[![Build Status][ci-badge]][ci-link] [![PyPI version][pypi-badge]][pypi-link]
<!-- [![codecov.io][cov-badge]][cov-link]
[cov-badge]: https://codecov.io/gh/executablebooks/mdformat-mkdocs/branch/main/graph/badge.svg
[cov-link]: https://codecov.io/gh/executablebooks/mdformat-mkdocs
-->
An [mdformat](https://github.com/executablebooks/mdformat) plugin for [mkdocs](https://github.com/mkdocs/mkdocs) and [mkdocs-material](https://squidfunk.github.io/mkdocs-material) in particular.
Supports:
- Indents are converted to 4-spaces instead of 2
- *Note*: see caveats when using the optional Semantic Indents on numbered lists which may not be a full multiple of 4
- Unordered list bullets are converted to dashes (`-`) instead of `*`
- By default, ordered lists are standardized on a single digit (`1.` or `0.`) unless `--number` is specified, then `mdformat-mkdocs` will apply consecutive numbering to ordered lists [for consistency with `mdformat`](https://github.com/executablebooks/mdformat?tab=readme-ov-file#options)
- standardized as all `1.` rather than incrementing
- Admonitions (extends [`mdformat-admon`](https://pypi.org/project/mdformat-admon))
- MKDocs-Material Content Tabs (<https://squidfunk.github.io/mkdocs-material/reference/content-tabs>)
- Note: the markup (HTML) rendered by this plugin is sufficient for formatting but not for viewing in a browser. Please open an issue if you have a need to generate valid HTML.
See the example test files, [./tests/pre-commit-test.md](https://raw.githubusercontent.com/KyleKing/mdformat-mkdocs/main/tests/pre-commit-test.md) and [./tests/format/fixtures.md](https://raw.githubusercontent.com/KyleKing/mdformat-mkdocs/main/tests/format/fixtures.md)
## `mdformat` Usage
Add this package wherever you use `mdformat` and the plugin will be auto-recognized. No additional configuration necessary. For additional information on plugins, see [the official `mdformat` documentation here](https://mdformat.readthedocs.io/en/stable/users/plugins.html)
**Tip**: this package specifies an "extra" (`'recommended'`) for plugins that work well with `mkdocs`:
- [mdformat-beautysh](https://pypi.org/project/mdformat-beautysh)
- [mdformat-black](https://pypi.org/project/mdformat-black)
- [mdformat-config](https://pypi.org/project/mdformat-config)
- [mdformat-footnote](https://pypi.org/project/mdformat-footnote)
- [mdformat-frontmatter](https://pypi.org/project/mdformat-frontmatter)
- [mdformat-simple-breaks](https://pypi.org/project/mdformat-simple-breaks)
- [mdformat-tables](https://pypi.org/project/mdformat-tables)
- [mdformat-web](https://pypi.org/project/mdformat-web)
- [mdformat-wikilink](https://github.com/tmr232/mdformat-wikilink)
### Pre-Commit
```yaml
repos:
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
hooks:
- id: mdformat
additional_dependencies:
- mdformat-mkdocs>=2.0.0
# Or
# - "mdformat-mkdocs[recommended]>=2.0.6"
```
### pipx
```sh
pipx install mdformat
pipx inject mdformat mdformat-mkdocs
# Or
# pipx inject mdformat "mdformat-mkdocs[recommended]"
```
## HTML Rendering
To generate HTML output, `mkdocs_admon_plugin` can be imported from `mdit_plugins`. More plugins will be added in the future. For more guidance on `MarkdownIt`, see the docs: <https://markdown-it-py.readthedocs.io/en/latest/using.html#the-parser>
```py
from markdown_it import MarkdownIt
from mdformat_mkdocs.mdit_plugins import mkdocs_admon_plugin
md = MarkdownIt()
md.use(mkdocs_admon_plugin)
text = "??? note\n content"
md.render(text)
# <details class="note">
# <summary>Note</summary>
# <p>content</p>
# </details>
```
## CLI Options
`mdformat-mkdocs` adds the CLI argument `--align-semantic-breaks-in-lists` to optionally align line breaks in numbered lists to 3-spaces. If not specified, the default of 4-indents is followed universally.
```txt
# with: mdformat
1. Semantic line feed where the following line is
three spaces deep
# vs. with: mdformat --align-semantic-breaks-in-lists
1. Semantic line feed where the following line is
three spaces deep
```
Note: the `align-semantic-breaks-in-lists` setting is not supported in the configuration file yet (https://github.com/executablebooks/mdformat/issues/378)
## Contributing
See [CONTRIBUTING.md](https://github.com/KyleKing/mdformat-mkdocs/blob/main/CONTRIBUTING.md)
[ci-badge]: https://github.com/kyleking/mdformat-mkdocs/workflows/CI/badge.svg?branch=main
[ci-link]: https://github.com/kyleking/mdformat-mkdocs/actions?query=workflow%3ACI+branch%3Amain+event%3Apush
[pypi-badge]: https://img.shields.io/pypi/v/mdformat-mkdocs.svg
[pypi-link]: https://pypi.org/project/mdformat-mkdocs
Raw data
{
"_id": null,
"home_page": null,
"name": "mdformat_mkdocs",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8.0",
"maintainer_email": null,
"keywords": "markdown, markdown-it, mdformat",
"author": null,
"author_email": "kyleking <dev.act.kyle@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/65/89/7945f4240974688b4afdce15160ad0bbfdd8134fdf38a4c12ee2da587c52/mdformat_mkdocs-2.0.10.tar.gz",
"platform": null,
"description": "# mdformat-mkdocs\n\n[![Build Status][ci-badge]][ci-link] [![PyPI version][pypi-badge]][pypi-link]\n\n<!-- [![codecov.io][cov-badge]][cov-link]\n[cov-badge]: https://codecov.io/gh/executablebooks/mdformat-mkdocs/branch/main/graph/badge.svg\n[cov-link]: https://codecov.io/gh/executablebooks/mdformat-mkdocs\n -->\n\nAn [mdformat](https://github.com/executablebooks/mdformat) plugin for [mkdocs](https://github.com/mkdocs/mkdocs) and [mkdocs-material](https://squidfunk.github.io/mkdocs-material) in particular.\n\nSupports:\n\n- Indents are converted to 4-spaces instead of 2\n - *Note*: see caveats when using the optional Semantic Indents on numbered lists which may not be a full multiple of 4\n- Unordered list bullets are converted to dashes (`-`) instead of `*`\n- By default, ordered lists are standardized on a single digit (`1.` or `0.`) unless `--number` is specified, then `mdformat-mkdocs` will apply consecutive numbering to ordered lists [for consistency with `mdformat`](https://github.com/executablebooks/mdformat?tab=readme-ov-file#options)\n- standardized as all `1.` rather than incrementing\n- Admonitions (extends [`mdformat-admon`](https://pypi.org/project/mdformat-admon))\n- MKDocs-Material Content Tabs (<https://squidfunk.github.io/mkdocs-material/reference/content-tabs>)\n - Note: the markup (HTML) rendered by this plugin is sufficient for formatting but not for viewing in a browser. Please open an issue if you have a need to generate valid HTML.\n\nSee the example test files, [./tests/pre-commit-test.md](https://raw.githubusercontent.com/KyleKing/mdformat-mkdocs/main/tests/pre-commit-test.md) and [./tests/format/fixtures.md](https://raw.githubusercontent.com/KyleKing/mdformat-mkdocs/main/tests/format/fixtures.md)\n\n## `mdformat` Usage\n\nAdd this package wherever you use `mdformat` and the plugin will be auto-recognized. No additional configuration necessary. For additional information on plugins, see [the official `mdformat` documentation here](https://mdformat.readthedocs.io/en/stable/users/plugins.html)\n\n**Tip**: this package specifies an \"extra\" (`'recommended'`) for plugins that work well with `mkdocs`:\n\n- [mdformat-beautysh](https://pypi.org/project/mdformat-beautysh)\n- [mdformat-black](https://pypi.org/project/mdformat-black)\n- [mdformat-config](https://pypi.org/project/mdformat-config)\n- [mdformat-footnote](https://pypi.org/project/mdformat-footnote)\n- [mdformat-frontmatter](https://pypi.org/project/mdformat-frontmatter)\n- [mdformat-simple-breaks](https://pypi.org/project/mdformat-simple-breaks)\n- [mdformat-tables](https://pypi.org/project/mdformat-tables)\n- [mdformat-web](https://pypi.org/project/mdformat-web)\n- [mdformat-wikilink](https://github.com/tmr232/mdformat-wikilink)\n\n### Pre-Commit\n\n```yaml\nrepos:\n - repo: https://github.com/executablebooks/mdformat\n rev: 0.7.16\n hooks:\n - id: mdformat\n additional_dependencies:\n - mdformat-mkdocs>=2.0.0\n # Or\n # - \"mdformat-mkdocs[recommended]>=2.0.6\"\n```\n\n### pipx\n\n```sh\npipx install mdformat\npipx inject mdformat mdformat-mkdocs\n# Or\n# pipx inject mdformat \"mdformat-mkdocs[recommended]\"\n```\n\n## HTML Rendering\n\nTo generate HTML output, `mkdocs_admon_plugin` can be imported from `mdit_plugins`. More plugins will be added in the future. For more guidance on `MarkdownIt`, see the docs: <https://markdown-it-py.readthedocs.io/en/latest/using.html#the-parser>\n\n```py\nfrom markdown_it import MarkdownIt\n\nfrom mdformat_mkdocs.mdit_plugins import mkdocs_admon_plugin\n\nmd = MarkdownIt()\nmd.use(mkdocs_admon_plugin)\n\ntext = \"??? note\\n content\"\nmd.render(text)\n# <details class=\"note\">\n# <summary>Note</summary>\n# <p>content</p>\n# </details>\n```\n\n## CLI Options\n\n`mdformat-mkdocs` adds the CLI argument `--align-semantic-breaks-in-lists` to optionally align line breaks in numbered lists to 3-spaces. If not specified, the default of 4-indents is followed universally.\n\n```txt\n# with: mdformat\n1. Semantic line feed where the following line is\n three spaces deep\n\n# vs. with: mdformat --align-semantic-breaks-in-lists\n1. Semantic line feed where the following line is\n three spaces deep\n```\n\nNote: the `align-semantic-breaks-in-lists` setting is not supported in the configuration file yet (https://github.com/executablebooks/mdformat/issues/378)\n\n## Contributing\n\nSee [CONTRIBUTING.md](https://github.com/KyleKing/mdformat-mkdocs/blob/main/CONTRIBUTING.md)\n\n[ci-badge]: https://github.com/kyleking/mdformat-mkdocs/workflows/CI/badge.svg?branch=main\n[ci-link]: https://github.com/kyleking/mdformat-mkdocs/actions?query=workflow%3ACI+branch%3Amain+event%3Apush\n[pypi-badge]: https://img.shields.io/pypi/v/mdformat-mkdocs.svg\n[pypi-link]: https://pypi.org/project/mdformat-mkdocs\n",
"bugtrack_url": null,
"license": null,
"summary": "An mdformat plugin for mkdocs.",
"version": "2.0.10",
"project_urls": {
"homepage": "https://github.com/kyleking/mdformat-mkdocs"
},
"split_keywords": [
"markdown",
" markdown-it",
" mdformat"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "b33dc0df3db573b5a61f0b2d00cc5e21470f9a084a4818fc55c8813d88a6ebcb",
"md5": "c51681772851367420d169412ded65d7",
"sha256": "34631680ac7a054e52df13bd77598473b42ac5994a2e1cf058a6635ba08028bb"
},
"downloads": -1,
"filename": "mdformat_mkdocs-2.0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c51681772851367420d169412ded65d7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8.0",
"size": 15368,
"upload_time": "2024-04-25T10:36:44",
"upload_time_iso_8601": "2024-04-25T10:36:44.095704Z",
"url": "https://files.pythonhosted.org/packages/b3/3d/c0df3db573b5a61f0b2d00cc5e21470f9a084a4818fc55c8813d88a6ebcb/mdformat_mkdocs-2.0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "65897945f4240974688b4afdce15160ad0bbfdd8134fdf38a4c12ee2da587c52",
"md5": "a5e5c19437fc7d7aecd696ca99df857a",
"sha256": "a1202da6d7a065dc90973457d0119dc14659df21320463e20564cfc4878028e1"
},
"downloads": -1,
"filename": "mdformat_mkdocs-2.0.10.tar.gz",
"has_sig": false,
"md5_digest": "a5e5c19437fc7d7aecd696ca99df857a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8.0",
"size": 17588,
"upload_time": "2024-04-25T10:36:45",
"upload_time_iso_8601": "2024-04-25T10:36:45.437317Z",
"url": "https://files.pythonhosted.org/packages/65/89/7945f4240974688b4afdce15160ad0bbfdd8134fdf38a4c12ee2da587c52/mdformat_mkdocs-2.0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-25 10:36:45",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kyleking",
"github_project": "mdformat-mkdocs",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "mdformat_mkdocs"
}