From: Vladimír Vondruš Date: Fri, 22 Feb 2019 18:30:09 +0000 (+0100) Subject: m.dot: support plaintext node shapes as well. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=90c0a5212afc35b5430d7014621d444c97c474cd;p=blog.git m.dot: support plaintext node shapes as well. --- diff --git a/pelican-plugins/dot2svg.py b/pelican-plugins/dot2svg.py index 6c68ce41..d7984d55 100644 --- a/pelican-plugins/dot2svg.py +++ b/pelican-plugins/dot2svg.py @@ -42,7 +42,7 @@ _comment_src = re.compile(r"""\n""") # Graphviz < 2.40 (Ubuntu 16.04 and older) doesn't have a linebreak between # and _class_src = re.compile(r"""<g id="(edge|node)\d+" class="(?P<type>edge|node)(?P<classes>[^"]*)">[\n]?<title>(?P<title>[^<]*) -<(?Pellipse|polygon|path) fill="(?P[^"]+)" stroke="[^"]+" """) +<(?Pellipse|polygon|path|text)( fill="(?P[^"]+)" stroke="[^"]+")? """) _class_dst = r""" {title} @@ -99,7 +99,10 @@ def dot2svg(source, size=None, attribs=''): def element_repl(match): classes = ['m-' + match.group('type')] + match.group('classes').replace('-', '-').split() # distinguish between solid and filled nodes - if match.group('type') == 'node' and match.group('fill') == 'none': + if ((match.group('type') == 'node' and match.group('fill') == 'none') or + # a plaintext node is also flat + match.group('element') == 'text' + ): classes += ['m-flat'] return _class_dst.format( diff --git a/pelican-plugins/m/test/dot/page-238.html b/pelican-plugins/m/test/dot/page-238.html index e8607d6d..f3118a8f 100644 --- a/pelican-plugins/m/test/dot/page-238.html +++ b/pelican-plugins/m/test/dot/page-238.html @@ -67,6 +67,17 @@ and the arrowheads, nothing else. Non-default font size should be preserved.

+
+ + +More shapes + +d +outsider + + + +

Colors:

diff --git a/pelican-plugins/m/test/dot/page.html b/pelican-plugins/m/test/dot/page.html index ff53a240..d23a177b 100644 --- a/pelican-plugins/m/test/dot/page.html +++ b/pelican-plugins/m/test/dot/page.html @@ -67,6 +67,17 @@ and the arrowheads, nothing else. Non-default font size should be preserved.

+
+ + +More shapes + +d +outsider + + + +

Colors:

diff --git a/pelican-plugins/m/test/dot/page.rst b/pelican-plugins/m/test/dot/page.rst index c3d09d29..36b7dcc7 100644 --- a/pelican-plugins/m/test/dot/page.rst +++ b/pelican-plugins/m/test/dot/page.rst @@ -18,6 +18,10 @@ and the arrowheads, nothing else. Non-default font size should be preserved. b -> c [label="0" fontsize=40] c -> c [label="1"] +.. digraph:: More shapes + + d [shape=plaintext label="outsider"] + Colors: .. digraph:: Colors