JSPM

pinyin-tone-convert

0.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 19
  • Score
    100M100P100Q65457F
  • License MIT

Convert Pinyin tone numbers to tone marks.

Package Exports

  • pinyin-tone-convert

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pinyin-tone-convert) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Pinyin Tone Convert

Build Status Coverage Status code style: prettier License: MIT

Easily convert pinyin tone numbers to tone marks.

Installation

npm install pinyin-tone-convert

Usage

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?

Options

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)

Conversion Rules

This library works based on these rules:

  1. a and e trump all other vowels and always take the tone mark.
  2. In the combination ou, o takes the mark.
  3. In all other cases, the final vowel takes the mark.

Tests

npm test

License

MIT.