Skip to content

Commit 5d39a1e

Browse files
doundDavid Underhill
authored andcommitted
support marking pinyin where tones may already be marked
1 parent 5fb19a1 commit 5d39a1e

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function convert(text, options) {
4545
* @returns {String} Word with marked tone
4646
*/
4747
function mark(word, toneNumber) {
48-
if (toneNumber === 5) {
48+
if (toneNumber === 5 || toneNumber === null) {
4949
return word
5050
}
5151

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pinyin-tone-convert",
3-
"version": "0.0.2",
3+
"version": "0.1.2",
44
"description": "Convert Pinyin tone numbers to tone marks.",
55
"main": "index.js",
66
"scripts": {
@@ -23,7 +23,7 @@
2323
},
2424
"homepage": "https://github.com/oleglegun/pinyin-tone-convert#readme",
2525
"dependencies": {
26-
"pinyin-tone-parse": "0.1.1"
26+
"pinyin-tone-parse": "git://github.com/dound/pinyin-tone-parse.git#a1efb3fb64d117f819086420814b89149fad1cfa"
2727
},
2828
"devDependencies": {
2929
"tap": "^12.0.1"

test/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@ const testCasesValid = [
77
text: 'Zhong1guo2ren2 ai4 he1 cha2 hai2shi5 ka1fei1?',
88
result: 'Zhōngguórén ài hē chá háishi kāfēi?',
99
},
10+
{
11+
options: { allowAnyChar: true },
12+
text: 'nǐhǎo。 yī,èr,sān!',
13+
result: 'nǐhǎo。 yī,èr,sān!'
14+
}
1015
]
1116

1217
testCasesValid.forEach(test => {
1318
tap.equal(toneConvert(test.text, test.options), test.result)
19+
// tone marks as input just get left as is
20+
tap.equal(toneConvert(toneConvert(test.text, test.options), { allowAnyChar: true }), test.result)
1421
})

0 commit comments

Comments
 (0)