# HG changeset patch # User Paul Boddie # Date 1688122357 -7200 # Node ID b1a50a92eb36c96f9c1197274542ad67e8d351d9 # Parent 9736f88a89849a5c1012f56d2d5e052c9711d6a4 Fixed document prettyprinting. diff -r 9736f88a8984 -r b1a50a92eb36 moinconvert --- a/moinconvert Fri Jun 30 00:40:39 2023 +0200 +++ b/moinconvert Fri Jun 30 12:52:37 2023 +0200 @@ -36,6 +36,10 @@ To indicate pagenames within an input directory, omit any --pagename flags.""" +message_tree_format_usage = """\ +The --tree and --format options cannot be used together since the --tree option +indicates use of the "pretty" format.""" + # Options management. @@ -152,6 +156,9 @@ # Detect tree output. elif arg == "--tree": + if formats: + print >>sys.stderr, message_tree_format_usage + sys.exit(1) tree = True # Options with following arguments. @@ -171,6 +178,9 @@ # Switch to collecting formats. elif arg == "--format": + if tree: + print >>sys.stderr, message_tree_format_usage + sys.exit(1) l = formats continue @@ -254,7 +264,7 @@ l = filenames - format = formats and formats[0] or "html" + format = tree and "pretty" or formats and formats[0] or "html" input_dir = getvalue(input_dirs) output_dir = getvalue(output_dirs) @@ -333,19 +343,17 @@ p.update_metadata(metadata) - # Show a document tree for debugging purposes, if requested. - - if tree: - print d.prettyprint() - continue - - # Otherwise, serialise the document. - # Obtain a serialiser using the configuration. serialiser = make_serialiser(metadata) outtext = serialise(d, serialiser) + # Show a document tree for debugging purposes, if requested. + + if tree: + print outtext + continue + # With a theme, apply it to the text. if theme: