book-text-util 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +3 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -637,7 +637,7 @@ function cnNumber(s) {
|
|
|
637
637
|
return total + cur;
|
|
638
638
|
}
|
|
639
639
|
function volumeNo(label) {
|
|
640
|
-
const m =
|
|
640
|
+
const m = /(?:^|[、,,;;\s])卷([\d〇零一二三四五六七八九十百]+)/.exec(label.trim());
|
|
641
641
|
return m ? cnNumber(m[1]) : null;
|
|
642
642
|
}
|
|
643
643
|
function wikiFileOf(no, chapters) {
|
package/dist/index.cjs
CHANGED
|
@@ -686,7 +686,7 @@ function cnNumber(s) {
|
|
|
686
686
|
return total + cur;
|
|
687
687
|
}
|
|
688
688
|
function volumeNo(label) {
|
|
689
|
-
const m =
|
|
689
|
+
const m = /(?:^|[、,,;;\s])卷([\d〇零一二三四五六七八九十百]+)/.exec(label.trim());
|
|
690
690
|
return m ? cnNumber(m[1]) : null;
|
|
691
691
|
}
|
|
692
692
|
function wikiFileOf(no, chapters) {
|
|
@@ -696,7 +696,7 @@ function wikiFileOf(no, chapters) {
|
|
|
696
696
|
return chapters.find((c) => volumeNo(c.title) === no)?.file ?? null;
|
|
697
697
|
}
|
|
698
698
|
function volumeRangeOf(title) {
|
|
699
|
-
const m =
|
|
699
|
+
const m = /(?:^|[、,,;;\s])卷([\d〇零一二三四五六七八九十百]+)(?:\s*[至到—–-]\s*卷?([\d〇零一二三四五六七八九十百]+))?/.exec(title.trim());
|
|
700
700
|
if (!m) return null;
|
|
701
701
|
const a = cnNumber(m[1]);
|
|
702
702
|
const b = m[2] ? cnNumber(m[2]) : a;
|
|
@@ -856,7 +856,7 @@ async function compareSeg(input, seg, out, idStart, whole, range) {
|
|
|
856
856
|
}
|
|
857
857
|
async function compareChapter(input) {
|
|
858
858
|
const range = input.volumeRange;
|
|
859
|
-
if (range && !input.headings.some((h) => h.level === 1)) {
|
|
859
|
+
if (range && !input.headings.some((h) => h.level === 1 && volumeNo(h.label) !== null)) {
|
|
860
860
|
const label = input.volumeLabel ?? (range[0] === range[1] ? `\u5377${range[0]}` : `\u5377${range[0]}\u81F3\u5377${range[1]}`);
|
|
861
861
|
const seg = { no: range[0], label, from: 0, to: input.cells.length, startsPartial: false, endsPartial: false, headEnd: 0 };
|
|
862
862
|
const items2 = [];
|
package/dist/index.js
CHANGED
|
@@ -615,7 +615,7 @@ function cnNumber(s) {
|
|
|
615
615
|
return total + cur;
|
|
616
616
|
}
|
|
617
617
|
function volumeNo(label) {
|
|
618
|
-
const m =
|
|
618
|
+
const m = /(?:^|[、,,;;\s])卷([\d〇零一二三四五六七八九十百]+)/.exec(label.trim());
|
|
619
619
|
return m ? cnNumber(m[1]) : null;
|
|
620
620
|
}
|
|
621
621
|
function wikiFileOf(no, chapters) {
|
|
@@ -625,7 +625,7 @@ function wikiFileOf(no, chapters) {
|
|
|
625
625
|
return chapters.find((c) => volumeNo(c.title) === no)?.file ?? null;
|
|
626
626
|
}
|
|
627
627
|
function volumeRangeOf(title) {
|
|
628
|
-
const m =
|
|
628
|
+
const m = /(?:^|[、,,;;\s])卷([\d〇零一二三四五六七八九十百]+)(?:\s*[至到—–-]\s*卷?([\d〇零一二三四五六七八九十百]+))?/.exec(title.trim());
|
|
629
629
|
if (!m) return null;
|
|
630
630
|
const a = cnNumber(m[1]);
|
|
631
631
|
const b = m[2] ? cnNumber(m[2]) : a;
|
|
@@ -785,7 +785,7 @@ async function compareSeg(input, seg, out, idStart, whole, range) {
|
|
|
785
785
|
}
|
|
786
786
|
async function compareChapter(input) {
|
|
787
787
|
const range = input.volumeRange;
|
|
788
|
-
if (range && !input.headings.some((h) => h.level === 1)) {
|
|
788
|
+
if (range && !input.headings.some((h) => h.level === 1 && volumeNo(h.label) !== null)) {
|
|
789
789
|
const label = input.volumeLabel ?? (range[0] === range[1] ? `\u5377${range[0]}` : `\u5377${range[0]}\u81F3\u5377${range[1]}`);
|
|
790
790
|
const seg = { no: range[0], label, from: 0, to: input.cells.length, startsPartial: false, endsPartial: false, headEnd: 0 };
|
|
791
791
|
const items2 = [];
|