1.1 --- a/moinconvert Fri Jun 30 16:11:00 2023 +0200
1.2 +++ b/moinconvert Fri Jun 30 22:06:08 2023 +0200
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 Moin wiki format converter.
1.6
1.7 -Copyright (C) 2018, 2019, 2021 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2018, 2019, 2021, 2023 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -37,8 +37,8 @@
1.13 To indicate pagenames within an input directory, omit any --pagename flags."""
1.14
1.15 message_tree_format_usage = """\
1.16 -The --tree and --format options cannot be used together since the --tree option
1.17 -indicates use of the "pretty" format."""
1.18 +The --tree option cannot be used together with the --format or --output-format
1.19 +options since the --tree option indicates use of the "pretty" format."""
1.20
1.21
1.22
1.23 @@ -92,7 +92,7 @@
1.24 attachments_dir = []
1.25 document_indexes = []
1.26 filenames = []
1.27 - formats = []
1.28 + input_formats = []
1.29 input_dir_types = []
1.30 input_dirs = []
1.31 input_encodings = []
1.32 @@ -100,6 +100,7 @@
1.33 mappings = []
1.34 output_dirs = []
1.35 output_encodings = []
1.36 + output_formats = []
1.37 output_page_seps = []
1.38 pagenames = []
1.39 root_pagenames = []
1.40 @@ -156,7 +157,7 @@
1.41 # Detect tree output.
1.42
1.43 elif arg == "--tree":
1.44 - if formats:
1.45 + if output_formats:
1.46 print >>sys.stderr, message_tree_format_usage
1.47 sys.exit(1)
1.48 tree = True
1.49 @@ -177,11 +178,11 @@
1.50
1.51 # Switch to collecting formats.
1.52
1.53 - elif arg == "--format":
1.54 + elif arg in ("--format", "--output-format"):
1.55 if tree:
1.56 print >>sys.stderr, message_tree_format_usage
1.57 sys.exit(1)
1.58 - l = formats
1.59 + l = output_formats
1.60 continue
1.61
1.62 # Switch to collecting input locations.
1.63 @@ -202,6 +203,12 @@
1.64 l = input_encodings
1.65 continue
1.66
1.67 + # Switch to collecting input formats.
1.68 +
1.69 + elif arg == "--input-format":
1.70 + l = input_formats
1.71 + continue
1.72 +
1.73 # Switch to collecting input page hierarchy separators.
1.74
1.75 elif arg == "--input-page-sep":
1.76 @@ -264,7 +271,8 @@
1.77
1.78 l = filenames
1.79
1.80 - format = tree and "pretty" or formats and formats[0] or "html"
1.81 + input_format = input_formats and input_formats[0] or "moin"
1.82 + output_format = tree and "pretty" or output_formats and output_formats[0] or "html"
1.83 input_dir = getvalue(input_dirs)
1.84 output_dir = getvalue(output_dirs)
1.85
1.86 @@ -280,18 +288,19 @@
1.87 "standalone",
1.88 "input_encoding" : getvalue(input_encodings),
1.89 "input_filename" : input_dir,
1.90 + "input_format" : input_format,
1.91 "input_separator" : getvalue(input_page_seps),
1.92 - "link_format" : format,
1.93 + "link_format" : output_format,
1.94 "mapping" : getmapping(mappings),
1.95 "no_inline" : no_inline,
1.96 "output_context" : output_dir and "directory" or "standalone",
1.97 "output_encoding" : getvalue(output_encodings),
1.98 - "output_format" : format,
1.99 + "output_format" : output_format,
1.100 "output_filename" : output_dir,
1.101 "output_separator" : getvalue(output_page_seps),
1.102 "root_pagename" : getvalue(root_pagenames, "FrontPage"),
1.103 "theme_name" : not fragment and \
1.104 - "%s.%s" % (getvalue(theme_names, "default"), format) or None,
1.105 + "%s.%s" % (getvalue(theme_names, "default"), output_format) or None,
1.106 })
1.107
1.108 # Define the input context and theme.
1.109 @@ -394,11 +403,13 @@
1.110
1.111 --common Obtain attachments from a common directory for all pages,
1.112 rather than each page having its own subdirectory of a
1.113 - top-level attachments directory.
1.114 + top-level attachments directory
1.115 --input-dir Indicate an input directory containing document files
1.116 --input-dir-type Indicate the type of input directory involved
1.117 (default: directory)
1.118 --input-encoding Indicate the character encoding used in document files
1.119 +--input-format Indicate the format of the parsed documents
1.120 + (default: moin)
1.121 --input-page-sep Indicate the separator used in filenames to encode
1.122 hierarchical relationships (subpages and descendant pages)
1.123 --pagename Indicate the page name corresponding to an indicated
1.124 @@ -409,20 +420,24 @@
1.125
1.126 --bundle Bundle resources such as stylesheets within every document,
1.127 useful for publishing documents that need to be copied or
1.128 - distributed individually.
1.129 + distributed individually
1.130 --document-index Provide a "DocumentIndex" filename to be used in links in
1.131 HTML format output, useful for local file browsing instead
1.132 of Web-published content
1.133 ---format Indicate the format to be used for serialised documents
1.134 +--format Indicate the format to be used for serialised documents;
1.135 + equivalent to --output-format
1.136 (default: html)
1.137 --fragment Indicates that an output fragment, not an entire document,
1.138 is to be generated, skipping any theming activities
1.139 --no-inline Suppress inline objects in serialised documents, linking to
1.140 - separate objects instead.
1.141 + separate objects instead
1.142 --output-dir Indicate an output directory to contain serialised document
1.143 files
1.144 --output-encoding Indicate the character encoding used in serialised document
1.145 files
1.146 +--output-format Indicate the format to be used for serialised documents;
1.147 + equivalent to --format
1.148 + (default: html)
1.149 --output-page-sep Indicate the separator used in filenames to encode
1.150 hierarchical relationships (subpages and descendant pages)
1.151 --theme Indicate a theme for serialised documents, typically
2.1 --- a/moinformat/parsers/__init__.py Fri Jun 30 16:11:00 2023 +0200
2.2 +++ b/moinformat/parsers/__init__.py Fri Jun 30 22:06:08 2023 +0200
2.3 @@ -3,7 +3,7 @@
2.4 """
2.5 Moin wiki parsers.
2.6
2.7 -Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk>
2.8 +Copyright (C) 2017, 2018, 2023 Paul Boddie <paul@boddie.org.uk>
2.9
2.10 This program is free software; you can redistribute it and/or modify it under
2.11 the terms of the GNU General Public License as published by the Free Software
2.12 @@ -30,7 +30,7 @@
2.13
2.14 return parsers[name]
2.15
2.16 -def make_parser(metadata, name="moin"):
2.17 +def make_parser(metadata, name=None):
2.18
2.19 "Return a parser instance using the given 'metadata' and optional 'name'."
2.20