Skip to content

Instantly share code, notes, and snippets.

@mornir
Created April 20, 2018 13:35
Show Gist options
  • Save mornir/df6633f26e68badc6a38ad1cc30c0ad5 to your computer and use it in GitHub Desktop.
Save mornir/df6633f26e68badc6a38ad1cc30c0ad5 to your computer and use it in GitHub Desktop.
Transform furigana
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