Created
April 20, 2018 13:35
-
-
Save mornir/df6633f26e68badc6a38ad1cc30c0ad5 to your computer and use it in GitHub Desktop.
Transform furigana
This file contains hidden or 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
const str = "I can speak {日本語,にほんご} read {漢字,かんじ}" | |
const regex = /{(\S+?),(\S+?)}/g | |
const newStr = str.replace(regex, ` | |
<ruby> | |
$1 <rp>(</rp><rt>$2</rt><rp>)</rp> | |
</ruby>`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment