File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change 44
55- [ pull #605 ] Add support for Python 3.13, drop EOL 3.8
66- [ pull #607 ] Fix ` middle-word-em ` extra preventing strongs from being recognized (#606 )
7+ - [ pull #609 ] Add option to output to file in CLI (#608 )
78
89
910## python-markdown2 2.5.1
Original file line number Diff line number Diff line change @@ -3985,6 +3985,7 @@ def main(argv=None):
39853985 help = "run internal self-tests (some doctests)" )
39863986 parser .add_argument ("--compare" , action = "store_true" ,
39873987 help = "run against Markdown.pl as well (for testing)" )
3988+ parser .add_argument ('--output' , type = str , help = 'output to a file instead of stdout' )
39883989 parser .set_defaults (log_level = logging .INFO , compare = False ,
39893990 encoding = "utf-8" , safe_mode = None , use_file_vars = False )
39903991 opts = parser .parse_args ()
@@ -4059,7 +4060,11 @@ def main(argv=None):
40594060 extras = extras , link_patterns = link_patterns ,
40604061 use_file_vars = opts .use_file_vars ,
40614062 cli = True )
4062- sys .stdout .write (html )
4063+ if opts .output :
4064+ with open (opts .output , 'w' ) as f :
4065+ f .write (html )
4066+ else :
4067+ sys .stdout .write (html )
40634068 if extras and "toc" in extras :
40644069 log .debug ("toc_html: " +
40654070 str (html .toc_html .encode (sys .stdout .encoding or "utf-8" , 'xmlcharrefreplace' )))
You can’t perform that action at this time.
0 commit comments