Created
March 13, 2013 00:42
-
-
Save menacestudio/5148452 to your computer and use it in GitHub Desktop.
Converts a Markdown file to HTML.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: Dennis Rongo | |
# Date: 03.12.2013 | |
# Description: Thie script converts a Markdown (*.md) file to HTML within the same directory. | |
# This requires Pandoc (http://johnmacfarlane.net/pandoc/) to do the conversion. | |
import sys | |
import getopt | |
import subprocess | |
def process(arg): | |
file = arg; | |
print 'Converting markdown to HTML' | |
subprocess.call("pandoc -o {file}.html {file}.md".format(file=file)) | |
# The argument takes in the name of the file without the extension. | |
def main(): | |
try: | |
opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) | |
except getopt.error, msg: | |
print msg | |
print "for help use --help" | |
sys.exit(2) | |
# process options | |
for o, a in opts: | |
if o in ("-h", "--help"): | |
print __doc__ | |
sys.exit(0) | |
# process arguments | |
for arg in args: | |
process(arg) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment