diff --git a/README.md b/README.md index 4969f33..c0e83ac 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [cov-link]: https://codecov.io/gh/executablebooks/mdformat-gfm-alerts --> -An [mdformat](https://github.com/executablebooks/mdformat) plugin for [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) (and [community discussion](https://github.com/orgs/community/discussions/16925)). +An [mdformat](https://github.com/executablebooks/mdformat) plugin for [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). "Alerts" are a block quote variation of admonitions that were proposed in this [community discussion](https://github.com/orgs/community/discussions/16925) and are currently a separate extension of the [GFM (GitHub-Flavored Markdown) syntax](https://github.github.com/gfm). ## `mdformat` Usage diff --git a/tests/fixtures.md b/tests/fixtures.md deleted file mode 100644 index 31d6be2..0000000 --- a/tests/fixtures.md +++ /dev/null @@ -1,24 +0,0 @@ -a test -. -This is the input Markdown test, -then below add the expected output. -. -This is the input Markdown test, -then below add the expected output. -. - -another test -. -Some *markdown* - -- a -- b -* c -. -Some *markdown* - -- a -- b - -* c -. diff --git a/tests/format/__init__.py b/tests/format/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/format/fixtures.md b/tests/format/fixtures.md new file mode 100644 index 0000000..9cc71d2 --- /dev/null +++ b/tests/format/fixtures.md @@ -0,0 +1,47 @@ +2023 Syntax +. +> [!NOTE] +> Useful information that users should know, even when skimming content. + +> [!TIP] +> Helpful advice for doing things better or more easily. + +> [!IMPORTANT] +> Key information users need to know to achieve their goal. + +> [!WARNING] +> Urgent info that needs immediate user attention to avoid problems. + +> [!CAUTION] +> Advises about risks or negative outcomes of certain actions. +. +> [!NOTE] +> Useful information that users should know, even when skimming content. + +> [!TIP] +> Helpful advice for doing things better or more easily. + +> [!IMPORTANT] +> Key information users need to know to achieve their goal. + +> [!WARNING] +> Urgent info that needs immediate user attention to avoid problems. + +> [!CAUTION] +> Advises about risks or negative outcomes of certain actions. +. + +2022 (to 2023) Syntax +. +> **Note** +> This is a note + +> **Warning** +> This is a warning +. +> [!NOTE] +> This is a note + +> [!WARNING] +> This is a warning +. diff --git a/tests/test_fixtures.py b/tests/format/test_fixtures.py similarity index 51% rename from tests/test_fixtures.py rename to tests/format/test_fixtures.py index 68fc3bf..cd35b91 100644 --- a/tests/test_fixtures.py +++ b/tests/format/test_fixtures.py @@ -1,17 +1,21 @@ from pathlib import Path -from markdown_it.utils import read_fixture_file import mdformat import pytest +from markdown_it.utils import read_fixture_file + +from ..helpers import print_text FIXTURE_PATH = Path(__file__).parent / "fixtures.md" fixtures = read_fixture_file(FIXTURE_PATH) @pytest.mark.parametrize( - "line,title,text,expected", fixtures, ids=[f[1] for f in fixtures] + ("line", "title", "text", "expected"), + fixtures, + ids=[f[1] for f in fixtures], ) def test_fixtures(line, title, text, expected): - output = mdformat.text(text, extensions={"plugin"}) - print(output) - assert output.rstrip() == expected.rstrip(), output + output = mdformat.text(text, extensions={"gfm_alerts"}) + print_text(output, expected) + assert output.rstrip() == expected.rstrip() diff --git a/tests/render/__init__.py b/tests/render/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_mdformat.py b/tests/test_mdformat.py new file mode 100644 index 0000000..13aae32 --- /dev/null +++ b/tests/test_mdformat.py @@ -0,0 +1,18 @@ +from pathlib import Path + +import mdformat + + +def test_mdformat_text(): + """Verify that using mdformat works as expected.""" + content = (Path(__file__).parent / "pre-commit-test.md").read_text() + + result = mdformat.text( + content, + options={"end-of-line": "keep"}, + extensions={ + "gfm_alerts", + }, + ) + + assert result == content