Created
January 24, 2012 20:59
-
-
Save skurfer/1672592 to your computer and use it in GitHub Desktop.
Convert change log to HTML and link issues
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
#!/usr/bin/env python | |
# -*- encoding: utf-8 -*- | |
import re | |
import codecs | |
import markdown | |
## get the original text | |
input_file = codecs.open("CHANGELOG", mode="r", encoding="utf8") | |
text = input_file.read() | |
## make issue numbers link to GitHub | |
text = re.sub(r'#(\d+)', u'[#\g<1>](https://github.com/quicksilver/Quicksilver/issues/\g<1>)', text) | |
## convert to HTML | |
md = markdown.Markdown(extensions = ['extra'], output_format = 'html4') | |
html = md.convert(text) | |
## write the result | |
output_file = codecs.open("Changes.html", "w", encoding="utf8") | |
output_file.write(u'<!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body>') | |
output_file.write(html) | |
output_file.write(u'</body></html>\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment