https://github.com/chanind/pinyin-tone-converter
https://github.com/chanind/pinyin-tone-converter
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/chanind/pinyin-tone-converter
- Owner: chanind
- License: mit
- Created: 2019-07-07T09:50:59.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T17:19:05.000Z (over 3 years ago)
- Last Synced: 2025-04-14T12:52:30.175Z (about 1 year ago)
- Language: TypeScript
- Size: 2.41 MB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: code-of-conduct.md
Awesome Lists containing this project
README
# Pinyin Tone Converter
[](https://circleci.com/gh/chanind/pinyin-tone-converter/tree/master)
[](https://coveralls.io/github/chanind/pinyin-tone-converter?branch=master)
[](https://www.npmjs.com/package/pinyin-tone-converter)
[](https://opensource.org/licenses/MIT)
A simple Javascript plugin to convert pinyin with numbers to tone marks.
This plugin is based on the [Quizlet Pinyin Converter](https://github.com/quizlet/pinyin-converter)
Works in node and in the browser. No external dependencies.
## Installation
`npm install pinyin-tone-converter`
## Usage
```js
import convertPinyinTones from 'pinyin-tone-converter';
convertPinyinTones('ni3hao3');
// returns 'nǐhǎo'
convertPinyinTones('san1ren2xing2bi4you3wo3shi1');
// returns "sānrénxíngbìyǒuwǒshī"
// ü can be typed by using v
convertPinyinTones('lv4');
// returns "lǜ"
// works with uppercase chars too
convertPinyinTones('WO3 HEN3 XI3HUAN QUIZLET!');
// returns "WǑ HĚN XǏHUAN QUIZLET!"
```
## License
pinyin-tone-converter is released under a [MIT License](https://opensource.org/licenses/MIT)
## Contributing
Contributions are welcome! These steps will guide you through contributing to this project:
- Fork the repo
- Clone it and install dependencies
`git clone https://github.com/chanind/pinyin-tone-converter`
`yarn install`
Make and commit your changes. Make sure the commands yarn run build and yarn run test:prod are working.
Finally send a [GitHub Pull Request](https://github.com/chanind/pinyin-tone-converter/compare?expand=1) with a clear list of what you've done. Make sure all of your commits are atomic (one feature per commit). Please add tests for any features that you add or change.
## Enjoy!