Easily convert pinyin tone numbers to tone marks.
npm install pinyin-tone-convert
const toneConvert = require('pinyin-tone-convert')
toneConvert('Ni3 hao3 ma5?')
// 'Nǐ hǎo ma?'
toneConvert('Zhong1guo2ren2 ai4 he1 cha2 hai2shi5 ka1fei1?')
// Zhōngguórén ài hē chá háishi kāfēi?Under the hood this library uses pinyin-tone-parse library and thus passes options object directly to it. Look for all available options here.
const toneConvert = require('pinyin-tone-convert')
toneConvert('pinyin...', options)This library works based on these rules:
aandetrump all other vowels and always take the tone mark.- In the combination
ou,otakes the mark. - In all other cases, the final vowel takes the mark.
npm test
MIT.