-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from AVATEAM-IT-SYSTEMHAUS/58-improve-handling…
…-of-the-fenced-code-blocks 58 improve handling of the fenced code blocks
- Loading branch information
Showing
7 changed files
with
238 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Test | ||
|
||
$code_block |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
site_name: Test pages for mkdocs-kroki-plugin | ||
|
||
theme: | ||
name: material | ||
|
||
plugins: | ||
- kroki: | ||
FencePrefix: '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
import pytest | ||
|
||
from tests.utils import MkDocsTemplateHelper | ||
|
||
TEST_CASES = { | ||
"#35": """ | ||
```` plantuml | ||
stuff containing ``` | ||
```` | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-119": """ | ||
``` mermaid | ||
< | ||
> | ||
``` | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-120": """ | ||
~~~ mermaid | ||
< | ||
> | ||
~~~ | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-122": """ | ||
``` mermaid | ||
aaa | ||
~~~ | ||
``` | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-123": """ | ||
~~~ mermaid | ||
aaa | ||
``` | ||
~~~ | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-125": """ | ||
~~~~ mermaid | ||
aaa | ||
~~~ | ||
~~~~ | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-129": """ | ||
``` mermaid | ||
``` | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-130": """ | ||
``` mermaid | ||
``` | ||
""", | ||
} | ||
|
||
TEST_CASES_NOT_SUPPORTED = { | ||
"https://spec.commonmark.org/0.31.2/#example-121": """ | ||
`` mermaid | ||
foo | ||
`` | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-124": """ | ||
```` mermaid | ||
aaa | ||
``` | ||
`````` | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-126": """ | ||
``` mermaid | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-127": """ | ||
````` mermaid | ||
``` | ||
aaa | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-128": """ | ||
> ``` mermaid | ||
> aaa | ||
bbb | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-131": """ | ||
``` mermaid | ||
aaa | ||
aaa | ||
``` | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-132": """ | ||
``` | ||
aaa | ||
aaa | ||
aaa | ||
``` | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-133": """ | ||
``` | ||
aaa | ||
aaa | ||
aaa | ||
``` | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-135": """ | ||
``` | ||
aaa | ||
``` | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-136": """ | ||
``` | ||
aaa | ||
``` | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-140": """ | ||
foo | ||
``` | ||
bar | ||
``` | ||
baz | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-141": """ | ||
foo | ||
--- | ||
~~~ | ||
bar | ||
~~~ | ||
# baz | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-146": """ | ||
~~~ aa ``` ~~~ | ||
foo | ||
~~~ | ||
""", | ||
"https://spec.commonmark.org/0.31.2/#example-147": """ | ||
``` | ||
``` aaa | ||
``` | ||
""", | ||
} | ||
|
||
TEST_CASES_ESCAPED = { | ||
"https://spec.commonmark.org/0.31.2/#example-134": """ | ||
``` | ||
aaa | ||
``` | ||
""", | ||
} | ||
|
||
|
||
@pytest.mark.parametrize("test_code_block", [pytest.param(v, id=k) for k, v in TEST_CASES.items()]) | ||
@pytest.mark.usefixtures("kroki_dummy") | ||
def test_fences(test_code_block) -> None: | ||
with MkDocsTemplateHelper(test_code_block) as mkdocs_helper: | ||
mkdocs_helper.set_http_method("POST") | ||
result = mkdocs_helper.invoke_build() | ||
|
||
assert result.exit_code == 0 | ||
image_files = list((mkdocs_helper.test_dir / "site").glob("*.svg")) | ||
assert len(image_files) == 1 | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"test_code_block", | ||
[pytest.param(v, id=k) for k, v in TEST_CASES_NOT_SUPPORTED.items()] | ||
+ [pytest.param(v, id=k) for k, v in TEST_CASES_ESCAPED.items()], | ||
) | ||
@pytest.mark.usefixtures("kroki_dummy") | ||
def test_fences_not_supported(test_code_block) -> None: | ||
with MkDocsTemplateHelper(test_code_block) as mkdocs_helper: | ||
mkdocs_helper.set_http_method("POST") | ||
result = mkdocs_helper.invoke_build() | ||
|
||
assert result.exit_code == 0 | ||
image_files = list((mkdocs_helper.test_dir / "site").glob("*.svg")) | ||
assert len(image_files) == 0 | ||
|
||
|
||
@pytest.mark.usefixtures("kroki_dummy") | ||
def test_pandoc_fenced_code_blocks() -> None: | ||
with MkDocsTemplateHelper("""~~~~~~~~~~~~~~~~ mermaid | ||
~~~~~~~~~~ | ||
code including tildes | ||
~~~~~~~~~~ | ||
~~~~~~~~~~~~~~~~""") as mkdocs_helper: | ||
mkdocs_helper.set_http_method("POST") | ||
result = mkdocs_helper.invoke_build() | ||
|
||
assert result.exit_code == 0 | ||
image_files = list((mkdocs_helper.test_dir / "site").glob("*.svg")) | ||
assert len(image_files) == 1 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters