Skip to content

Instantly share code, notes, and snippets.

@aristotll
Forked from huangziwei/markdown_furigana.py
Created December 12, 2015 12:54
Show Gist options
  • Save aristotll/8f4b55b0503437e9b364 to your computer and use it in GitHub Desktop.
Save aristotll/8f4b55b0503437e9b364 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