import markdown, string #http://www.freewisdom.org/projects/python-markdown/Installation textfile = open('markdowntest.txt','r') title = "" tags = [] while True: optionline = textfile.readline() if string.strip(optionline) == '%%%': break; if string.find(optionline, "Title:") == 0: title = string.strip(optionline[6:]) if string.find(optionline, "Tags:") == 0: tags = string.split(string.strip(optionline[5:]),",") newtaglist = [] for tag in tags: newtaglist.append(string.strip(tag)) tags = list(newtaglist) postbody = textfile.read() textfile.close() #print postbody html = markdown.markdown(postbody) writefilename = title+".txt" writefile = open(writefilename,'w') writefile.write(html) writefile.close() print "HTML saved to %s." % writefilename