Skip to content

Commit d1652c8

Browse files
LingDong-Lingdong Huang
authored andcommitted
fix import macro
1 parent 65ab2b0 commit d1652c8

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/macro.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
function extractMacros(txt, { lib, reader, lang }) {
22
function getImports() {
33
var imps = [];
4+
var qlvl = 0;
45
for (var i = 0; i < txt.length; i++) {
6+
if (txt[i] == "「") {
7+
qlvl++;
8+
} else if (txt[i] == "」") {
9+
qlvl--;
10+
} else if (txt[i] == "『") {
11+
qlvl += 2;
12+
} else if (txt[i] == "』") {
13+
qlvl -= 2;
14+
}
15+
if (qlvl != 0) {
16+
continue;
17+
}
518
if (txt[i] == "吾" && txt[i + 1] == "嘗" && txt[i + 2] == "觀") {
619
var imp = txt
720
.slice(i + 3)
@@ -90,7 +103,7 @@ function extractMacros(txt, { lib, reader, lang }) {
90103
}
91104
}
92105
}
93-
s0 = s0.replace(/[]/g, "(.*?)");
106+
s0 = s0.replace(/[]/g, "(.+?)");
94107
macs.push([s0, s1]);
95108
i = j;
96109
}

tools/test_parser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ function runAll(lang, skips = []) {
5454

5555
// runExample("js", "quicksort");
5656
// runExample("js", "../lib/js/畫譜");
57-
runExample("js", "../lib/曆法");
57+
// runExample("js", "../lib/曆法");
5858
// runAll("js", ["quine", "quine2", "tree", "tree2", "try"]);
5959
// runAll("js", ["quine"]);
6060

61-
// runExample("js", "../../../Downloads/local_test");
61+
runExample("js", "../../../Downloads/local_test");
6262
// runExample("py", "draw_heart");

0 commit comments

Comments
 (0)