Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Answer file maintained by Copier for: https://github.com/KyleKing/mdformat-plugin-template
# DO NOT MODIFY THIS FILE. Edit by re-running copier and changing responses to the questions
# Check into version control.
_commit: 1.0.2
_commit: 1.1.4
_src_path: gh:KyleKing/mdformat-plugin-template
author_email: [email protected]
author_name: Kyle King
Expand All @@ -13,4 +13,5 @@ plugin_name: mkdocs
repository_namespace: kyleking
repository_provider: https://github.com
repository_url: https://github.com/kyleking/mdformat-mkdocs
sync_admon_factories: true

26 changes: 14 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
---
name: CI

"on":
push:
branches: [main]
tags: [v*]
pull_request: null

jobs:
pre-commit:
runs-on: ubuntu-latest
Expand All @@ -15,6 +17,7 @@ jobs:
with:
python-version: 3.12
- uses: pre-commit/[email protected]

tests:
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -30,22 +33,20 @@ jobs:
- name: Installation (deps and package)
# We install with flit --pth-file, so that coverage will be recorded for the module
# Flit could be installed with pipx and use '--python=$(which python)', but
# there are issues with the Windows Runner
# there were issues with the Windows Runner
run: |
pip install flit~=3.9
pip install flit~=3.10.1
flit install --deps=production --extras=test --pth-file
- name: Run pytest
run: |
pytest --cov=$(ls | grep "mdformat_" | head) --cov-report=xml --cov-report=term-missing
# Not currently configured
# - name: Upload to Codecov
# if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.12
# uses: codecov/codecov-action@v1
pytest --cov
# # Not currently configured
# - name: Report coverage
# if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
# uses: codecov/codecov-action@v4
# with:
# name: pytests-py3.12
# flags: pytests
# file: ./coverage.xml
# fail_ci_if_error: true
# token: ${{ secrets.CODECOV_TOKEN }}

pre-commit-hook:
runs-on: ubuntu-latest
steps:
Expand All @@ -61,6 +62,7 @@ jobs:
- name: run pre-commit with plugin
run: |
pre-commit run --config .pre-commit-test.yaml --all-files --verbose --show-diff-on-failure

publish:
name: Publish to PyPi
needs: [pre-commit, tests, pre-commit-hook]
Expand All @@ -74,7 +76,7 @@ jobs:
uses: actions/checkout@v4
- name: install flit
run: |
pipx install flit~=3.9
pipx install flit~=3.10.1
- name: Build and publish
run: |
flit publish
Expand Down
2 changes: 0 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ repos:
- id: end-of-file-fixer
exclude: \.copier-answers\.yml|__snapshots__/.*\.ambr
- id: fix-byte-order-marker
- id: fix-encoding-pragma
args: [--remove]
- id: forbid-new-submodules
- id: mixed-line-ending
args: [--fix=auto]
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To install these development dependencies:

```bash
pipx install tox
# or: uv tool install tox
# or: uv tool install tox --with tox-uv
```

To run the tests:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Executable Books
Copyright (c) 2024 Kyle King

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 1 addition & 7 deletions mdformat_mkdocs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,4 @@
# https://github.com/executablebooks/mdformat/blob/5d9b573ce33bae219087984dd148894c774f41d4/src/mdformat/plugins.py
from .plugin import POSTPROCESSORS, RENDERERS, add_cli_options, update_mdit

__all__ = (
"POSTPROCESSORS",
"RENDERERS",
"__version__",
"add_cli_options",
"update_mdit",
)
__all__ = ("POSTPROCESSORS", "RENDERERS", "add_cli_options", "update_mdit")
6 changes: 3 additions & 3 deletions mdformat_mkdocs/_postprocess_inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ def postprocess_list_wrap(
):
return text

_counter = -1
counter_ = -1
parent = node.parent
while parent and parent.type == "paragraph":
parent = parent.parent
_counter += 1
indent_count = max(_counter, 0)
counter_ += 1
indent_count = max(counter_, 0)

soft_break = "\x00"
text = text.lstrip(soft_break).lstrip()
Expand Down
Empty file.
25 changes: 25 additions & 0 deletions mdformat_mkdocs/_synced/admon_factories/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Admonition/Callout Factories

This code is useful to format and render admonitions similar to Python Markdown's format

If you are looking to add `mdformat` to your project to format a specific syntax, you will want to use one of the below plugins:

- [`mdformat-admon`](https://github.com/KyleKing/mdformat-admon)
- [`python-markdown` admonitions](https://python-markdown.github.io/extensions/admonition)
- [`mdformat-mkdocs`](https://github.com/KyleKing/mdformat-mkdocs)
- [MKDocs Admonitions](https://squidfunk.github.io/mkdocs-material/reference/admonitions)
- [`mdformat-gfm-alerts`](https://github.com/KyleKing/mdformat-gfm-alerts)
- Primarily supports [Github "Alerts"](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts), but indirectly also supports
- [Microsoft "Alerts"](https://learn.microsoft.com/en-us/contribute/content/markdown-reference#alerts-note-tip-important-caution-warning)
- [Mozilla Callouts](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Howto/Markdown_in_MDN#notes_warnings_and_callouts)
- [`mdformat-obsidian`](https://github.com/KyleKing/mdformat-obsidian)
- [Obsidian Callouts](https://help.obsidian.md/How+to/Use+callouts)

However, directive-style admonition formats are not known to be supported by an existing mdformat plugin nor by the utility code in this directory as it exists today:

- [node.js markdown-it-container](https://github.com/markdown-it/markdown-it-container)
- [MyST](https://myst-parser.readthedocs.io/en/latest/syntax/roles-and-directives.html)
- [Sphinx Directives](https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html)
- [reStructuredText](https://docutils.sourceforge.io/docs/ref/rst/directives.html#specific-admonitions)
- [pymdown-extensions](https://facelessuser.github.io/pymdown-extensions/extensions/blocks/plugins/admonition)
- [PyMDown](https://facelessuser.github.io/pymdown-extensions/extensions/blocks/plugins/admonition)
15 changes: 15 additions & 0 deletions mdformat_mkdocs/_synced/admon_factories/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from ._whitespace_admon_factories import (
AdmonitionData,
admon_plugin_factory,
new_token,
parse_possible_whitespace_admon_factory,
parse_tag_and_title,
)

__all__ = (
"AdmonitionData",
"admon_plugin_factory",
"new_token",
"parse_possible_whitespace_admon_factory",
"parse_tag_and_title",
)
Loading
Loading