Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function convert(text, options) {
* @returns {String} Word with marked tone
*/
function mark(word, toneNumber) {
if (toneNumber === 5) {
if (toneNumber === 5 || toneNumber === null) {
return word
}

Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pinyin-tone-convert",
"version": "0.0.2",
"version": "0.1.2",
"description": "Convert Pinyin tone numbers to tone marks.",
"main": "index.js",
"scripts": {
Expand All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/oleglegun/pinyin-tone-convert#readme",
"dependencies": {
"pinyin-tone-parse": "0.1.1"
"pinyin-tone-parse": "dound/pinyin-tone-parse#a1efb3fb64d117f819086420814b89149fad1cfa"
},
"devDependencies": {
"tap": "^12.0.1"
Expand Down
7 changes: 7 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ const testCasesValid = [
text: 'Zhong1guo2ren2 ai4 he1 cha2 hai2shi5 ka1fei1?',
result: 'Zhōngguórén ài hē chá háishi kāfēi?',
},
{
options: { allowAnyChar: true },
text: 'nǐhǎo。 yī,èr,sān!',
result: 'nǐhǎo。 yī,èr,sān!'
}
]

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