From 502adac89c6352ddfc9f214f2d2dcd22187a332c Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Mon, 18 Apr 2022 14:55:32 -0500 Subject: [PATCH] make the pydot syntax backwards compatible with code fences without this, the code fence parser was getting thrown off if you didn't have the pydot extension loaded, which was thwarting backwards compatibility. this makes the pydot bits look like an attribute to the vanilla parser, so at least then the vanilla markdown renders as intended --- incorporealcms/mdx/pydot.py | 2 +- tests/instance/pages/test-graphviz.md | 2 +- tests/instance/pages/test-invalid-graphviz.md | 2 +- tests/instance/pages/test-two-graphviz.md | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/incorporealcms/mdx/pydot.py b/incorporealcms/mdx/pydot.py index a995905..db8cf8f 100644 --- a/incorporealcms/mdx/pydot.py +++ b/incorporealcms/mdx/pydot.py @@ -20,7 +20,7 @@ class InlinePydot(markdown.Extension): class InlinePydotPreprocessor(markdown.preprocessors.Preprocessor): """Identify dot codeblocks and run them through pydot.""" - BLOCK_RE = re.compile(r'~~~pydot:(?P[^\s]+)\n(?P.*?)~~~', re.DOTALL) + BLOCK_RE = re.compile(r'~~~{\s+pydot:(?P[^\s]+)\s+}\n(?P.*?)~~~', re.DOTALL) def run(self, lines): """Match and generate diagrams from dot code blocks.""" diff --git a/tests/instance/pages/test-graphviz.md b/tests/instance/pages/test-graphviz.md index c2ad5c3..b425c8e 100644 --- a/tests/instance/pages/test-graphviz.md +++ b/tests/instance/pages/test-graphviz.md @@ -1,7 +1,7 @@ # test test -~~~pydot:attack-plan +~~~{ pydot:attack-plan } digraph G { rankdir=LR Earth diff --git a/tests/instance/pages/test-invalid-graphviz.md b/tests/instance/pages/test-invalid-graphviz.md index 27727f8..8b3a08a 100644 --- a/tests/instance/pages/test-invalid-graphviz.md +++ b/tests/instance/pages/test-invalid-graphviz.md @@ -1,7 +1,7 @@ # test test -~~~pydot:attack-plan +~~~{ pydot:attack-plan } rankdir=LR Earth Mars diff --git a/tests/instance/pages/test-two-graphviz.md b/tests/instance/pages/test-two-graphviz.md index 97f7c31..df3ef48 100644 --- a/tests/instance/pages/test-two-graphviz.md +++ b/tests/instance/pages/test-two-graphviz.md @@ -2,7 +2,7 @@ test -~~~pydot:attack-plan +~~~{ pydot:attack-plan } digraph G { rankdir=LR Earth @@ -13,7 +13,7 @@ digraph G { more test -~~~pydot:new-attack-plan +~~~{ pydot:new-attack-plan } digraph H { rankdir=LR Venus