Last active
March 2, 2016 08:55
-
-
Save huangziwei/28cd70c4926c497b8b73 to your computer and use it in GitHub Desktop.
a python script for writing furigana in markdown
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
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