Skip to content

Instantly share code, notes, and snippets.

@jkr
Created June 20, 2014 15:01
Show Gist options
  • Save jkr/a8fbe639dd3b58537313 to your computer and use it in GitHub Desktop.
Save jkr/a8fbe639dd3b58537313 to your computer and use it in GitHub Desktop.
Convert smart markdown to dumb markdown
#!/usr/bin/env python3
import sys
if sys.version_info[0] != 3:
sys.exit("Must use python3")
replacements = {0x2013: '--',
0x2014: '---',
0x201c: '"',
0x201d: '"',
0x2018: "'",
0x2019: "'",
0x2026: '...',
0xa0: ' '}
text = sys.stdin.read()
for r in replacements:
text = text.replace(chr(r), replacements[r])
print(text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment