Bug fixes and features #1
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
CHAPTER_MARKER = '## '
|
CHAPTER_MARKER = '## '
|
||||||
|
@ -26,6 +27,14 @@ def count_words(line):
|
||||||
def main():
|
def main():
|
||||||
arguments = sys.argv[1:]
|
arguments = sys.argv[1:]
|
||||||
filename = arguments[0]
|
filename = arguments[0]
|
||||||
|
tmpfilename = None
|
||||||
|
|
||||||
|
if '-pp' in arguments:
|
||||||
|
import MarkdownPP
|
||||||
|
tmpfilename = f'.tmp-{os.getpid}.md'
|
||||||
|
MarkdownPP.MarkdownPP(input=open(filename), output=open(tmpfilename,'w'), modules=list(MarkdownPP.modules))
|
||||||
|
|||||||
|
filename = tmpfilename
|
||||||
|
|
||||||
chapter_heading = None
|
chapter_heading = None
|
||||||
act_heading = None
|
act_heading = None
|
||||||
total_word_count = 0
|
total_word_count = 0
|
||||||
|
@ -102,6 +111,9 @@ def main():
|
||||||
|
|
||||||
print('total: {:,} words'.format(total_word_count))
|
print('total: {:,} words'.format(total_word_count))
|
||||||
|
|
||||||
|
if tmpfilename:
|
||||||
|
os.remove(tmpfilename)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
witten
commented
Code changes look great! At some point it'd probably be good to switch to "formal" argument parsing ( Code changes look great! At some point it'd probably be good to switch to "formal" argument parsing (`argparse`, etc.), but certainly not needed now.
|
|||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user
Clever!