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
This commit is contained in:
Brian S. Stephan 2022-04-18 14:55:32 -05:00
parent 08305e26db
commit 502adac89c
Signed by: bss
GPG Key ID: 3DE06D3180895FCB
4 changed files with 5 additions and 5 deletions

View File

@ -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<filename>[^\s]+)\n(?P<content>.*?)~~~', re.DOTALL)
BLOCK_RE = re.compile(r'~~~{\s+pydot:(?P<filename>[^\s]+)\s+}\n(?P<content>.*?)~~~', re.DOTALL)
def run(self, lines):
"""Match and generate diagrams from dot code blocks."""

View File

@ -1,7 +1,7 @@
# test
test
~~~pydot:attack-plan
~~~{ pydot:attack-plan }
digraph G {
rankdir=LR
Earth

View File

@ -1,7 +1,7 @@
# test
test
~~~pydot:attack-plan
~~~{ pydot:attack-plan }
rankdir=LR
Earth
Mars

View File

@ -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