Skip to content

Commit 74a6619

Browse files
authored
Merge pull request #44 from KyleKing/fix-admon-22
2 parents 360f86a + 687c7cd commit 74a6619

27 files changed

+586
-109
lines changed

.copier-answers.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Answer file maintained by Copier for: https://github.com/KyleKing/mdformat-plugin-template
33
# DO NOT MODIFY THIS FILE. Edit by re-running copier and changing responses to the questions
44
# Check into version control.
5-
_commit: 1.0.2
5+
_commit: 1.1.4
66
_src_path: gh:KyleKing/mdformat-plugin-template
77
author_email: [email protected]
88
author_name: Kyle King
@@ -13,4 +13,5 @@ plugin_name: mkdocs
1313
repository_namespace: kyleking
1414
repository_provider: https://github.com
1515
repository_url: https://github.com/kyleking/mdformat-mkdocs
16+
sync_admon_factories: true
1617

.github/workflows/tests.yml

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
---
22
name: CI
3+
34
"on":
45
push:
56
branches: [main]
67
tags: [v*]
78
pull_request: null
9+
810
jobs:
911
pre-commit:
1012
runs-on: ubuntu-latest
@@ -15,6 +17,7 @@ jobs:
1517
with:
1618
python-version: 3.12
1719
- uses: pre-commit/[email protected]
20+
1821
tests:
1922
runs-on: ${{ matrix.os }}
2023
strategy:
@@ -30,22 +33,20 @@ jobs:
3033
- name: Installation (deps and package)
3134
# We install with flit --pth-file, so that coverage will be recorded for the module
3235
# Flit could be installed with pipx and use '--python=$(which python)', but
33-
# there are issues with the Windows Runner
36+
# there were issues with the Windows Runner
3437
run: |
35-
pip install flit~=3.9
38+
pip install flit~=3.10.1
3639
flit install --deps=production --extras=test --pth-file
3740
- name: Run pytest
3841
run: |
39-
pytest --cov=$(ls | grep "mdformat_" | head) --cov-report=xml --cov-report=term-missing
40-
# Not currently configured
41-
# - name: Upload to Codecov
42-
# if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.12
43-
# uses: codecov/codecov-action@v1
42+
pytest --cov
43+
# # Not currently configured
44+
# - name: Report coverage
45+
# if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
46+
# uses: codecov/codecov-action@v4
4447
# with:
45-
# name: pytests-py3.12
46-
# flags: pytests
47-
# file: ./coverage.xml
48-
# fail_ci_if_error: true
48+
# token: ${{ secrets.CODECOV_TOKEN }}
49+
4950
pre-commit-hook:
5051
runs-on: ubuntu-latest
5152
steps:
@@ -61,6 +62,7 @@ jobs:
6162
- name: run pre-commit with plugin
6263
run: |
6364
pre-commit run --config .pre-commit-test.yaml --all-files --verbose --show-diff-on-failure
65+
6466
publish:
6567
name: Publish to PyPi
6668
needs: [pre-commit, tests, pre-commit-hook]
@@ -74,7 +76,7 @@ jobs:
7476
uses: actions/checkout@v4
7577
- name: install flit
7678
run: |
77-
pipx install flit~=3.9
79+
pipx install flit~=3.10.1
7880
- name: Build and publish
7981
run: |
8082
flit publish

.pre-commit-config.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ repos:
1818
- id: end-of-file-fixer
1919
exclude: \.copier-answers\.yml|__snapshots__/.*\.ambr
2020
- id: fix-byte-order-marker
21-
- id: fix-encoding-pragma
22-
args: [--remove]
2321
- id: forbid-new-submodules
2422
- id: mixed-line-ending
2523
args: [--fix=auto]

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ To install these development dependencies:
1515

1616
```bash
1717
pipx install tox
18-
# or: uv tool install tox
18+
# or: uv tool install tox --with tox-uv
1919
```
2020

2121
To run the tests:

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Executable Books
3+
Copyright (c) 2024 Kyle King
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

mdformat_mkdocs/__init__.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,4 @@
66
# https://github.com/executablebooks/mdformat/blob/5d9b573ce33bae219087984dd148894c774f41d4/src/mdformat/plugins.py
77
from .plugin import POSTPROCESSORS, RENDERERS, add_cli_options, update_mdit
88

9-
__all__ = (
10-
"POSTPROCESSORS",
11-
"RENDERERS",
12-
"__version__",
13-
"add_cli_options",
14-
"update_mdit",
15-
)
9+
__all__ = ("POSTPROCESSORS", "RENDERERS", "add_cli_options", "update_mdit")

mdformat_mkdocs/_postprocess_inline.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ def postprocess_list_wrap(
4141
):
4242
return text
4343

44-
_counter = -1
44+
counter_ = -1
4545
parent = node.parent
4646
while parent and parent.type == "paragraph":
4747
parent = parent.parent
48-
_counter += 1
49-
indent_count = max(_counter, 0)
48+
counter_ += 1
49+
indent_count = max(counter_, 0)
5050

5151
soft_break = "\x00"
5252
text = text.lstrip(soft_break).lstrip()

mdformat_mkdocs/_synced/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Admonition/Callout Factories
2+
3+
This code is useful to format and render admonitions similar to Python Markdown's format
4+
5+
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:
6+
7+
- [`mdformat-admon`](https://github.com/KyleKing/mdformat-admon)
8+
- [`python-markdown` admonitions](https://python-markdown.github.io/extensions/admonition)
9+
- [`mdformat-mkdocs`](https://github.com/KyleKing/mdformat-mkdocs)
10+
- [MKDocs Admonitions](https://squidfunk.github.io/mkdocs-material/reference/admonitions)
11+
- [`mdformat-gfm-alerts`](https://github.com/KyleKing/mdformat-gfm-alerts)
12+
- 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
13+
- [Microsoft "Alerts"](https://learn.microsoft.com/en-us/contribute/content/markdown-reference#alerts-note-tip-important-caution-warning)
14+
- [Mozilla Callouts](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Howto/Markdown_in_MDN#notes_warnings_and_callouts)
15+
- [`mdformat-obsidian`](https://github.com/KyleKing/mdformat-obsidian)
16+
- [Obsidian Callouts](https://help.obsidian.md/How+to/Use+callouts)
17+
18+
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:
19+
20+
- [node.js markdown-it-container](https://github.com/markdown-it/markdown-it-container)
21+
- [MyST](https://myst-parser.readthedocs.io/en/latest/syntax/roles-and-directives.html)
22+
- [Sphinx Directives](https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html)
23+
- [reStructuredText](https://docutils.sourceforge.io/docs/ref/rst/directives.html#specific-admonitions)
24+
- [pymdown-extensions](https://facelessuser.github.io/pymdown-extensions/extensions/blocks/plugins/admonition)
25+
- [PyMDown](https://facelessuser.github.io/pymdown-extensions/extensions/blocks/plugins/admonition)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from ._whitespace_admon_factories import (
2+
AdmonitionData,
3+
admon_plugin_factory,
4+
new_token,
5+
parse_possible_whitespace_admon_factory,
6+
parse_tag_and_title,
7+
)
8+
9+
__all__ = (
10+
"AdmonitionData",
11+
"admon_plugin_factory",
12+
"new_token",
13+
"parse_possible_whitespace_admon_factory",
14+
"parse_tag_and_title",
15+
)

0 commit comments

Comments
 (0)