diff options
author | Raymond Hettinger <python@rcn.com> | 2012-07-04 00:55:23 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2012-07-04 00:55:23 (GMT) |
commit | 5b381a3650e9f79b3db48a5ee44e60b7cc20fb15 (patch) | |
tree | 3db13ddcad56bf2805f6c99ca1f62a6e89959ef2 /Tools | |
parent | 0712f40308ad48a2d3c3175211c9bde6084f1eae (diff) | |
download | cpython-5b381a3650e9f79b3db48a5ee44e60b7cc20fb15.zip cpython-5b381a3650e9f79b3db48a5ee44e60b7cc20fb15.tar.gz cpython-5b381a3650e9f79b3db48a5ee44e60b7cc20fb15.tar.bz2 |
Make ANSI the default output style
Diffstat (limited to 'Tools')
-rwxr-xr-x | Tools/scripts/highlight.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/Tools/scripts/highlight.py b/Tools/scripts/highlight.py index 022e02d..74f8649 100755 --- a/Tools/scripts/highlight.py +++ b/Tools/scripts/highlight.py @@ -4,7 +4,7 @@ Example command-line calls: # Show syntax highlighted code in the terminal window - $ ./highlight.py -a myfile.py + $ ./highlight.py myfile.py # Colorize myfile.py and display in a browser $ ./highlight.py -b myfile.py @@ -13,7 +13,7 @@ Example command-line calls: ./highlight.py -s myfile.py # Create a complete HTML file - $ ./highlight.py myfile.py > myfile.html + $ ./highlight.py -c myfile.py > myfile.html ''' @@ -149,31 +149,28 @@ if __name__ == '__main__': description = 'Add syntax highlighting to Python source') parser.add_argument('sourcefile', metavar = 'SOURCEFILE', help = 'File containing Python sourcecode') - parser.add_argument('-a', '--ansi', action = 'store_true', - help = 'emit ANSI escape highlighted source') parser.add_argument('-b', '--browser', action = 'store_true', help = 'launch a browser to show results') + parser.add_argument('-c', '--complete', action = 'store_true', + help = 'build a complete html webpage') parser.add_argument('-s', '--section', action = 'store_true', help = 'show an HTML section rather than a complete webpage') args = parser.parse_args() - if args.browser and args.section: + if args.section and (args.browser or args.complete): parser.error('The -s/--section option is incompatible with ' - 'the -b/--browser option') - if args.ansi and (args.browser or args.section): - parser.error('The -a/--ansi option is incompatible with ' - 'the -b/--browser and -s/--section options') + 'the -b/--browser or -c/--complete options') sourcefile = args.sourcefile with open(sourcefile) as f: source = f.read() - if args.ansi: - encoded = colorize_ansi(source) + if args.complete or args.browser: + encoded = build_page(source, title=sourcefile) elif args.section: encoded = colorize_html(source) else: - encoded = build_page(source, title=sourcefile) + encoded = colorize_ansi(source) if args.browser: htmlfile = os.path.splitext(os.path.basename(sourcefile))[0] + '.html' |