Skip to content

Instantly share code, notes, and snippets.

@huangziwei
Last active March 2, 2016 08:55
Show Gist options
  • Save huangziwei/28cd70c4926c497b8b73 to your computer and use it in GitHub Desktop.
Save huangziwei/28cd70c4926c497b8b73 to your computer and use it in GitHub Desktop.
a python script for writing furigana in markdown
import fileinput
import re
import sys
```
eg. [東京]{とうきょう} -> <ruby>東京<rp>(</rp><rt>とうきょう</rt><rp>)</rp></ruby>
```
for line in fileinput.input(sys.argv[1:], inplace=True):
line = re.sub(r'\[(.*?)\]\{(.*?)\}', r'<ruby>\1<rp>(</rp><rt>\2</rt><rp>)</rp></ruby>', line.rstrip())
print(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment