# HG changeset patch # User Paul Boddie # Date 1576021672 -3600 # Node ID b8cfafd45f264be92ce5acaa8cafad2ad0d489b8 # Parent 5356499387d3ca868359a4f844757c4be32dc1d0# Parent ef27cbaadc7486db92b32fad2cf38b59a06de8f4 Merged concurrent branches. diff -r 5356499387d3 -r b8cfafd45f26 moinconvert --- a/moinconvert Thu Oct 24 18:50:53 2019 +0200 +++ b/moinconvert Wed Dec 11 00:47:52 2019 +0100 @@ -108,8 +108,10 @@ all = False bundle = False + common = False fragment = False macros = False + no_inline = False tree = False for arg in args: @@ -126,6 +128,11 @@ elif arg == "--bundle": bundle = True + # Detect use of a common attachments directory. + + elif arg == "--common": + common = True + # Detect fragment output (if serialising). elif arg == "--fragment": @@ -136,6 +143,11 @@ elif arg == "--macros": macros = True + # Detect suppression of inline objects. + + elif arg == "--no-inline": + no_inline = True + # Detect tree output. elif arg == "--tree": @@ -244,6 +256,7 @@ metadata = Metadata({ "attachments" : getvalue(attachments_dir, "attachments"), "bundle" : bundle, + "common_attachments": common, "document_index" : getvalue(document_indexes), "input_context" : input_dir and \ getvalue(input_dir_types, "directory") or \ @@ -253,6 +266,7 @@ "input_separator" : getvalue(input_page_seps), "link_format" : format, "mapping" : getmapping(mappings), + "no_inline" : no_inline, "output_context" : output_dir and "directory" or "standalone", "output_encoding" : getvalue(output_encodings), "output_format" : format, @@ -362,6 +376,9 @@ Input options: +--common Obtain attachments from a common directory for all pages, + rather than each page having its own subdirectory of a + top-level attachments directory. --input-dir Indicate an input directory containing document files --input-dir-type Indicate the type of input directory involved (default: directory) @@ -384,6 +401,8 @@ (default: html) --fragment Indicates that an output fragment, not an entire document, is to be generated, skipping any theming activities +--no-inline Suppress inline objects in serialised documents, linking to + separate objects instead. --output-dir Indicate an output directory to contain serialised document files --output-encoding Indicate the character encoding used in serialised document diff -r 5356499387d3 -r b8cfafd45f26 moinformat/input/directory.py --- a/moinformat/input/directory.py Thu Oct 24 18:50:53 2019 +0200 +++ b/moinformat/input/directory.py Wed Dec 11 00:47:52 2019 +0100 @@ -53,6 +53,19 @@ self.attachments_dir = metadata.get("attachments") + # Support a common attachments directory. + + self.common_attachments = metadata.get("common_attachments") + + def _get_attachments_dir(self, pagename): + + "Return the attachments directory for 'pagename'." + + if self.common_attachments: + return join(self.dir.filename, self.attachments_dir) + else: + return join(self.dir.filename, self.attachments_dir, pagename) + def all(self): "Return all pages in the context." @@ -74,11 +87,7 @@ is relative to the appropriate attachment directory. """ - attachments_dir = Directory(join(self.dir.filename, - self.attachments_dir, - pagename)) - - return attachments_dir.select_files("*") + return Directory(self._get_attachments_dir(pagename)).select_files("*") # Page characteristics. @@ -118,8 +127,8 @@ if not pagename: return None - return self.dir.get_filename(join(self.attachments_dir, - pagename, filename)) + return self.dir.get_filename(join(self._get_attachments_dir(pagename), + filename)) # NOTE: Translation methods should encode filenames appropriately. diff -r 5356499387d3 -r b8cfafd45f26 moinformat/serialisers/html/graphviz.py --- a/moinformat/serialisers/html/graphviz.py Thu Oct 24 18:50:53 2019 +0200 +++ b/moinformat/serialisers/html/graphviz.py Wed Dec 11 00:47:52 2019 +0100 @@ -22,6 +22,7 @@ from moinformat.serialisers.common import Serialiser, escape_attr, escape_text from moinformat.utils.graphviz import Graphviz, IMAGE_FORMATS, \ get_output_identifier +from moinformat.utils.links import LinkTarget # Utility functions. @@ -107,7 +108,7 @@ # Determine the inline status, with only SVG being appropriate. - inline = format == "svg" + inline = format == "svg" and not self.metadata.get("no_inline") # Non-inline graph output is stored for a known page only. @@ -131,7 +132,7 @@ # Make sure that page attachments can be stored. self.output.ensure_attachments(pagename) - link = self.linker.translate("attachment:%s" % attachment) + link = self.linker.translate(LinkTarget("attachment", attachment)) # No filename is defined for inline output.