Created
April 2, 2016 23:07
-
-
Save thecapacity/adbd7ef9b508891b7f61f92b063bbd97 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# -*- coding: ascii -*- | |
### Sample Usage: for f in `ls *.md`; do html_unescape.py $f > ok && mv ok $f; done | |
import sys | |
import codecs | |
import HTMLParser | |
h = HTMLParser.HTMLParser() | |
def convert_html(filename): | |
f = open(filename, "r") | |
text = h.unescape( codecs.open(filename, "r", "utf-8").read() ) | |
# text = h.unescape( f.read() ) | |
return text.encode('utf-8') | |
if __name__ == "__main__": | |
print convert_html( sys.argv[1] ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use via base with something to the effect of;
for f in *.md; do html_unescape.py $f > ok && mv ok $f done