chiark / gitweb /
m.dot: support plaintext node shapes as well.
authorVladimír Vondruš <mosra@centrum.cz>
Fri, 22 Feb 2019 18:30:09 +0000 (19:30 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Sat, 23 Feb 2019 00:00:22 +0000 (01:00 +0100)
pelican-plugins/dot2svg.py
pelican-plugins/m/test/dot/page-238.html
pelican-plugins/m/test/dot/page.html
pelican-plugins/m/test/dot/page.rst

index 6c68ce414228ec2a51f6eca409eaa38a8eb52a2a..d7984d5533a0cbf124d41fc0616401c3386ae716 100644 (file)
@@ -42,7 +42,7 @@ _comment_src = re.compile(r"""<!--[^-]+-->\n""")
 # Graphviz < 2.40 (Ubuntu 16.04 and older) doesn't have a linebreak between <g>
 # and <title>
 _class_src = re.compile(r"""<g id="(edge|node)\d+" class="(?P<type>edge|node)(?P<classes>[^"]*)">[\n]?<title>(?P<title>[^<]*)</title>
-<(?P<element>ellipse|polygon|path) fill="(?P<fill>[^"]+)" stroke="[^"]+" """)
+<(?P<element>ellipse|polygon|path|text)( fill="(?P<fill>[^"]+)" stroke="[^"]+")? """)
 
 _class_dst = r"""<g class="{classes}">
 <title>{title}</title>
@@ -99,7 +99,10 @@ def dot2svg(source, size=None, attribs=''):
     def element_repl(match):
         classes = ['m-' + match.group('type')] + match.group('classes').replace('&#45;', '-').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(
index e8607d6d8a0107b55ff37f0c3903d1d8155bc606..f3118a8f7440a72c07ed2312fd1cf4b99dce4ac1 100644 (file)
@@ -67,6 +67,17 @@ and the arrowheads, nothing else. Non-default font size should be preserved.</p>
 </g>
 </svg>
 </div>
+<div class="m-graph">
+<svg style="width: 5.625rem; height: 2.750rem;" viewBox="0.00 0.00 90.00 44.00">
+<g transform="scale(1 1) rotate(0) translate(4 40)">
+<title>More shapes</title>
+<g class="m-node m-flat">
+<title>d</title>
+<text text-anchor="middle" x="41" y="-14.2">outsider</text>
+</g>
+</g>
+</svg>
+</div>
 <p>Colors:</p>
 <div class="m-graph">
 <svg style="width: 5.750rem; height: 8.500rem;" viewBox="0.00 0.00 92.38 135.54">
index ff53a24021eff875194ce505f46c7797e3ccdae0..d23a177b253d5c5d88964a203eef424707454c44 100644 (file)
@@ -67,6 +67,17 @@ and the arrowheads, nothing else. Non-default font size should be preserved.</p>
 </g>
 </svg>
 </div>
+<div class="m-graph">
+<svg style="width: 5.562rem; height: 2.750rem;" viewBox="0.00 0.00 89.00 44.00">
+<g transform="scale(1 1) rotate(0) translate(4 40)">
+<title>More shapes</title>
+<g class="m-node m-flat">
+<title>d</title>
+<text text-anchor="middle" x="40.5" y="-14.2">outsider</text>
+</g>
+</g>
+</svg>
+</div>
 <p>Colors:</p>
 <div class="m-graph">
 <svg style="width: 5.688rem; height: 8.500rem;" viewBox="0.00 0.00 91.38 135.54">
index c3d09d29d8ec163004c3a82270393f332e94544f..36b7dcc737eac04ccd1cdb9febe5f9ceffaa5945 100644 (file)
@@ -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