1.1 --- a/moinformat/serialisers/html/graphviz.py Tue Nov 27 21:23:24 2018 +0100
1.2 +++ b/moinformat/serialisers/html/graphviz.py Tue Nov 27 22:48:12 2018 +0100
1.3 @@ -97,27 +97,36 @@
1.4 format = self.directives.get("format", ["svg"])[0]
1.5 transforms = self.directives.get("transform", [])
1.6
1.7 - # Graph output is stored for a known page only.
1.8 + inline = format == "svg"
1.9 +
1.10 + # Non-inline graph output is stored for a known page only.
1.11
1.12 pagename = self.metadata.get("pagename")
1.13 - if not pagename:
1.14 - return
1.15 +
1.16 + if not inline:
1.17 + if not pagename:
1.18 + return
1.19
1.20 - # Get an identifier and usable filename to store the output.
1.21 + # Get an identifier and usable filename to store the output.
1.22
1.23 - identifier = get_output_identifier(text)
1.24 - attachment = "%s.%s" % (identifier, format)
1.25 - filename = self.output.get_attachment_filename(pagename, attachment)
1.26 + identifier = get_output_identifier(text)
1.27 + attachment = "%s.%s" % (identifier, format)
1.28 + filename = self.output.get_attachment_filename(pagename, attachment)
1.29 +
1.30 + # Handle situations where no independent output is permitted.
1.31
1.32 - # Handle situations where no independent output is permitted.
1.33 + if not filename:
1.34 + return
1.35
1.36 - if not filename:
1.37 - return
1.38 + # Make sure that page attachments can be stored.
1.39
1.40 - # Make sure that page attachments can be stored.
1.41 + self.output.ensure_attachments(pagename)
1.42 + target, _label = self.linker.translate("attachment:%s" % attachment)
1.43
1.44 - self.output.ensure_attachments(pagename)
1.45 - target, label = self.linker.translate("attachment:%s" % attachment)
1.46 + # No filename is defined for inline output.
1.47 +
1.48 + else:
1.49 + filename = None
1.50
1.51 # Permit imagemaps only for image formats.
1.52
1.53 @@ -126,7 +135,7 @@
1.54
1.55 # Configure Graphviz and invoke it.
1.56
1.57 - graphviz = Graphviz(filter, text, identifier)
1.58 + graphviz = Graphviz(filter, text)
1.59 graphviz.call(format, transforms, filename)
1.60
1.61 # Obtain any metadata.
1.62 @@ -151,8 +160,13 @@
1.63
1.64 # For other output, create a file and embed the object.
1.65
1.66 + elif not inline:
1.67 + self.object(target, attributes)
1.68 +
1.69 + # Or for inline output, emit it in the document itself.
1.70 +
1.71 else:
1.72 - self.object(target, attributes)
1.73 + self.out(graphviz.get_inline_output())
1.74
1.75 serialiser = HTMLGraphvizSerialiser
1.76