Skip to content

Instantly share code, notes, and snippets.

@emmettbutler
Created February 17, 2014 17:18
Show Gist options
  • Save emmettbutler/9054918 to your computer and use it in GitHub Desktop.
Save emmettbutler/9054918 to your computer and use it in GitHub Desktop.
Script that wraps jedie's python-creole for the command line
# coding: utf-8
# https://github.com/jedie/python-creole
# convert a rest file to HTML (for blog)
import sys
import os.path
import re
from creole.rest2html.clean_writer import rest2html
if len(sys.argv) < 2:
print "Usage: %s [filename]" % __file__
sys.exit()
try:
with open(sys.argv[1], "r") as text:
path,name = os.path.split(sys.argv[1])
name = "%s.html" % name.split('.')[0]
f = open(name, "w+")
text = re.sub("tt>", "code>", rest2html(text.read()))
f.write(text)
f.close()
print "Wrote new file %s" % name
except IOError as e:
print "File not found!"
sys.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment