Skip to content

Commit c25016d

Browse files
authored
Merge pull request #465 from Fros1er/master
fix: 書之 prints "true", "false" instead of "陽", "陰"
2 parents ee7d686 + 1dbc2f3 commit c25016d

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

src/hanzi2num.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,13 @@ function num2hanzi(n, format = "", precision = undefined) {
849849
return str;
850850
}
851851

852+
function bool2hanzi(b) {
853+
if (b) {
854+
return "陽";
855+
}
856+
return "陰";
857+
}
858+
852859
try {
853-
module.exports = { hanzi2num, hanzi2numstr, num2hanzi };
860+
module.exports = { hanzi2num, hanzi2numstr, num2hanzi, bool2hanzi };
854861
} catch (e) {}

src/parser.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
try {
2-
var { hanzi2num, hanzi2numstr, num2hanzi } = require("./hanzi2num");
2+
var { hanzi2num, hanzi2numstr, num2hanzi, bool2hanzi } = require("./hanzi2num");
33
var hanzi2pinyin = require("./hanzi2pinyin");
44
var STDLIB = require("./stdlib");
55
var { NUMBER_KEYWORDS, KEYWORDS } = require("./keywords");
@@ -761,6 +761,7 @@ var parser = {
761761
hanzi2num,
762762
hanzi2numstr,
763763
num2hanzi,
764+
bool2hanzi,
764765
hanzi2pinyin,
765766
KEYWORDS,
766767
NUMBER_KEYWORDS,

tools/make_ide.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ function main() {
166166
for (var i = 0; i < arguments.length; i++) {
167167
if (typeof arguments[i] == "number") {
168168
outdiv.innerText += num2hanzi(arguments[i]);
169+
} else if (typeof arguments[i] == "boolean") {
170+
outdiv.innerText += bool2hanzi(arguments[i]);
169171
} else {
170172
outdiv.innerText += arguments[i];
171173
}

tools/make_site.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ function main() {
8787
for (var i = 1; i < arguments.length; i++) {
8888
if (typeof arguments[i] == "number") {
8989
outdiv.innerText += num2hanzi(arguments[i]);
90+
} else if (typeof arguments[i] == "boolean") {
91+
outdiv.innerText += bool2hanzi(arguments[i]);
9092
} else {
9193
outdiv.innerText += arguments[i];
9294
}

0 commit comments

Comments
 (0)