# HG changeset patch # User Paul Boddie # Date 1565185680 -7200 # Node ID ef27cbaadc7486db92b32fad2cf38b59a06de8f4 # Parent bfe1bea63e68704f2cbb57e33afdcd9b7fbc53d0 Added support for not inlining objects that would otherwise appear inline. Also added some support for a common attachments input directory for all pages. diff -r bfe1bea63e68 -r ef27cbaadc74 moinconvert --- a/moinconvert Wed Aug 07 15:44:50 2019 +0200 +++ b/moinconvert Wed Aug 07 15:48:00 2019 +0200 @@ -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 bfe1bea63e68 -r ef27cbaadc74 moinformat/input/directory.py --- a/moinformat/input/directory.py Wed Aug 07 15:44:50 2019 +0200 +++ b/moinformat/input/directory.py Wed Aug 07 15:48:00 2019 +0200 @@ -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 bfe1bea63e68 -r ef27cbaadc74 moinformat/serialisers/html/graphviz.py --- a/moinformat/serialisers/html/graphviz.py Wed Aug 07 15:44:50 2019 +0200 +++ b/moinformat/serialisers/html/graphviz.py Wed Aug 07 15:48:00 2019 +0200 @@ -108,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.