import argparse import re import sys HEAD = """
""" def convert_markdown_into_html(argv=None): parser = argparse.ArgumentParser() parser.add_argument('filenames', nargs='*', help='Filenames to fix') args = parser.parse_args(argv) retv = 0 for filename in args.filenames: with open( re.sub(r"README", "index", re.sub(r"\.md$", ".html", filename)), "w", encoding="utf-8") as output: output.write(HEAD) with open(filename, encoding="utf-8") as input: for line in input: output.write(line) output.write(TAIL) return retv if __name__ == '__main__': sys.exit(convert_markdown_into_html())