tag-checker 0.0.85 → 0.0.89
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/package.json +1 -1
- package/src/analyzeTag.js +14 -14
- package/src/checkHead.js +4 -3
- package/src/checkPbOrder.js +6 -4
- package/src/checkTagFormat.js +2 -2
- package/src/detectTag.js +4 -4
- package/src/getTagRules.js +9 -9
package/package.json
CHANGED
package/src/analyzeTag.js
CHANGED
|
@@ -2,8 +2,8 @@ const volAnalyzeRegex = /<vol n="((\d+?)(-(\d+?))?)"/;
|
|
|
2
2
|
const sutraRegex = /<sutra id="[\da-zA-Z]*?[a-zA-Z]((\d+?)([a-zA-Z])?)"/;
|
|
3
3
|
const headAnalyzeRegex = /<head n="(\d+?)" (t|bo|tw|en|cn)="(.+?)"/;
|
|
4
4
|
const bampoRegex = /<bampo n="((\d+?)([a-zA-Z])?)\.(\d+?)"/;
|
|
5
|
-
const pb4AnalyzeRegex = /<pb id="((\d+?)-(\d+?))-((\d+?)([abcd]))"/;
|
|
6
|
-
const pbAnalyzeRegex = /<pb id="((\d+?)-(\d+?))-(\d+?)"/;
|
|
5
|
+
const pb4AnalyzeRegex = /<pb id="((\d+?)(-(\d+?))?)-((\d+?)([abcd]))"/;
|
|
6
|
+
const pbAnalyzeRegex = /<pb id="((\d+?)(-(\d+?))?)-(\d+?)"/;
|
|
7
7
|
|
|
8
8
|
export function analyzeVol(fn, tagStr) {
|
|
9
9
|
let volBio = volAnalyzeRegex.exec(tagStr);
|
|
@@ -14,7 +14,7 @@ export function analyzeVol(fn, tagStr) {
|
|
|
14
14
|
vol1n: Number(volBio[2]),
|
|
15
15
|
vol2n: Number(volBio[4])
|
|
16
16
|
};
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
18
|
|
|
19
19
|
export function analyzeSutra(fn, pb, tag) {
|
|
20
20
|
let sutraBio = sutraRegex.exec(tag);
|
|
@@ -27,7 +27,7 @@ export function analyzeSutra(fn, pb, tag) {
|
|
|
27
27
|
sutraN: Number(sutraBio[2]),
|
|
28
28
|
sutraL: sutraBio[3]
|
|
29
29
|
}
|
|
30
|
-
}
|
|
30
|
+
}
|
|
31
31
|
|
|
32
32
|
export function analyzeHead(fn, pb, tag) {
|
|
33
33
|
let headBio = headAnalyzeRegex.exec(tag);
|
|
@@ -39,7 +39,7 @@ export function analyzeHead(fn, pb, tag) {
|
|
|
39
39
|
headN: Number(headBio[1]),
|
|
40
40
|
tName: headBio[2]
|
|
41
41
|
};
|
|
42
|
-
}
|
|
42
|
+
}
|
|
43
43
|
|
|
44
44
|
export function analyzeBampo(fn, pb, tag) {
|
|
45
45
|
let bampoBio = bampoRegex.exec(tag);
|
|
@@ -53,7 +53,7 @@ export function analyzeBampo(fn, pb, tag) {
|
|
|
53
53
|
sutraL: bampoBio[3],
|
|
54
54
|
bampoN: Number(bampoBio[4])
|
|
55
55
|
};
|
|
56
|
-
}
|
|
56
|
+
}
|
|
57
57
|
|
|
58
58
|
export function analyzePb4(fn, tagStr) {
|
|
59
59
|
let pb4Bio = pb4AnalyzeRegex.exec(tagStr);
|
|
@@ -62,12 +62,12 @@ export function analyzePb4(fn, tagStr) {
|
|
|
62
62
|
tag: pb4Bio[0],
|
|
63
63
|
pbVolN: pb4Bio[1],
|
|
64
64
|
pbVol1n: Number(pb4Bio[2]),
|
|
65
|
-
pbVol2n: Number(pb4Bio[
|
|
66
|
-
pbNL: pb4Bio[
|
|
67
|
-
pbN: Number(pb4Bio[
|
|
68
|
-
pbL: pb4Bio[
|
|
65
|
+
pbVol2n: pb4Bio[4] ? Number(pb4Bio[4]) : 1,
|
|
66
|
+
pbNL: pb4Bio[5],
|
|
67
|
+
pbN: Number(pb4Bio[6]),
|
|
68
|
+
pbL: pb4Bio[7]
|
|
69
69
|
};
|
|
70
|
-
}
|
|
70
|
+
}
|
|
71
71
|
|
|
72
72
|
export function analyzePb(fn, tagStr) {
|
|
73
73
|
let pbBio = pbAnalyzeRegex.exec(tagStr);
|
|
@@ -76,7 +76,7 @@ export function analyzePb(fn, tagStr) {
|
|
|
76
76
|
tag: pbBio[0],
|
|
77
77
|
pbVolN: pbBio[1],
|
|
78
78
|
pbVol1n: Number(pbBio[2]),
|
|
79
|
-
pbVol2n: Number(pbBio[
|
|
80
|
-
pbN: Number(pbBio[
|
|
79
|
+
pbVol2n: pbBio[4] ? Number(pbBio[4]) : 1,
|
|
80
|
+
pbN: Number(pbBio[5])
|
|
81
81
|
};
|
|
82
|
-
}
|
|
82
|
+
}
|
package/src/checkHead.js
CHANGED
|
@@ -22,7 +22,8 @@ export default function checkHeadN(textObjs) {
|
|
|
22
22
|
check1stHeadAndOrder(errMessages, lastHeadBio, headBio, followVol);
|
|
23
23
|
// checkTname(fn, pbId, tag, headBio.tName)
|
|
24
24
|
|
|
25
|
-
lastHeadBio = headBio
|
|
25
|
+
lastHeadBio = headBio;
|
|
26
|
+
followVol = false;
|
|
26
27
|
}
|
|
27
28
|
else {
|
|
28
29
|
followVol = true;
|
|
@@ -31,7 +32,7 @@ export default function checkHeadN(textObjs) {
|
|
|
31
32
|
});
|
|
32
33
|
|
|
33
34
|
reportErr('Wrong Head Order!', errMessages);
|
|
34
|
-
}
|
|
35
|
+
}
|
|
35
36
|
|
|
36
37
|
function check1stHeadAndOrder(store, lastBio, bio, followVol) {
|
|
37
38
|
let {fn, pb, tag, headN} = bio;
|
|
@@ -56,7 +57,7 @@ function check1stHead(store, headN, bioMessage) {
|
|
|
56
57
|
function checkHeadOrder(lastHeadN, headN, lastBioMessage, bioMessage) {
|
|
57
58
|
if (headN - lastHeadN > 1) {
|
|
58
59
|
warn('Head n might be missing!', lastBioMessage, bioMessage);
|
|
59
|
-
}
|
|
60
|
+
}
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
function checkTname(fn, pbId, tag, tname) {
|
package/src/checkPbOrder.js
CHANGED
|
@@ -35,7 +35,7 @@ export default function checkPbOrder(textObjs, pbWithSuffix) {
|
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
reportErr('Wrong Pb Order!', errMessages);
|
|
38
|
-
}
|
|
38
|
+
}
|
|
39
39
|
|
|
40
40
|
function init(textObj, pbWithSuffix) {
|
|
41
41
|
let {fn, text} = textObj;
|
|
@@ -98,15 +98,17 @@ function pbIs1st(pbId) {
|
|
|
98
98
|
function setVariables(textObj, textsVol1n, pbAnalyzer) {
|
|
99
99
|
let {fn, text} = textObj;
|
|
100
100
|
let volInText = volExist(text);
|
|
101
|
+
let textVol1n;
|
|
101
102
|
if (volInText) {
|
|
102
103
|
var volBio = analyzeVol(fn, text);
|
|
103
|
-
|
|
104
|
+
textVol1n = volBio.vol1n;
|
|
104
105
|
}
|
|
105
106
|
else if (textsVol1n) {
|
|
106
|
-
|
|
107
|
+
textVol1n = textsVol1n;
|
|
107
108
|
}
|
|
108
109
|
else {
|
|
109
|
-
|
|
110
|
+
let { pbVol1n } = pbAnalyzer(fn, text);
|
|
111
|
+
textVol1n = pbVol1n;
|
|
110
112
|
}
|
|
111
113
|
return [fn, text, volInText, volBio, textVol1n];
|
|
112
114
|
}
|
package/src/checkTagFormat.js
CHANGED
|
@@ -6,7 +6,7 @@ import {sameNumber} from './compareNumber.js';
|
|
|
6
6
|
const emptyTagRegex = /<[\s\/]*>/g;
|
|
7
7
|
const noEndArrowRegex = /<[^>]*?(<|\n|$)/g;
|
|
8
8
|
const noStartArrowRegex = /(^|\n|>)[^<\n]*?>/g;
|
|
9
|
-
const undefinedTagRegex = /<(?!(division|vol|head|pb|jp|sutra|bampo|headnote|\/?stitle|\/?ttitle|\/?small|d|pedurma|note|\/?s|V|L|D|M|WB|graphic|\/?voltext)).+/g;
|
|
9
|
+
const undefinedTagRegex = /<(?!(division|vol|head|pb|jp|mp|sutra|bampo|headnote|\/?stitle|\/?ttitle|\/?small|d|pedurma|note|\/?s|V|L|D|M|WB|g|graphic|\/?voltext)).+/g;
|
|
10
10
|
|
|
11
11
|
export default function checkTagFormat(textObjs, pbWithSuffix, looseMode) {
|
|
12
12
|
let errMessages = [];
|
|
@@ -40,7 +40,7 @@ export default function checkTagFormat(textObjs, pbWithSuffix, looseMode) {
|
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
reportErr('Wrong Tag Format', errMessages);
|
|
43
|
-
}
|
|
43
|
+
}
|
|
44
44
|
|
|
45
45
|
function checkPropFormat(fn, text, tagRules) {
|
|
46
46
|
let wrongPropFormats = [];
|
package/src/detectTag.js
CHANGED
|
@@ -6,15 +6,15 @@ const pbWithSuffix = /<pb id="\d+?-(\d+?-)?\d+?[abcd]"\/>/;
|
|
|
6
6
|
|
|
7
7
|
export function detectPbType(str) {
|
|
8
8
|
return pbWithSuffix.test(str);
|
|
9
|
-
}
|
|
9
|
+
}
|
|
10
10
|
|
|
11
11
|
export function volExist(str) {
|
|
12
12
|
return vol.test(str);
|
|
13
|
-
}
|
|
13
|
+
}
|
|
14
14
|
|
|
15
15
|
export function headExist(str) {
|
|
16
16
|
return head.test(str);
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
18
|
|
|
19
19
|
export function bampoExist(str) {
|
|
20
20
|
return bampo.test(str);
|
|
@@ -22,4 +22,4 @@ export function bampoExist(str) {
|
|
|
22
22
|
|
|
23
23
|
export function pbExist(str, regex = pb) {
|
|
24
24
|
return regex.test(str);
|
|
25
|
-
}
|
|
25
|
+
}
|
package/src/getTagRules.js
CHANGED
|
@@ -36,56 +36,56 @@ let tagRules = [
|
|
|
36
36
|
correctRegex: /^<pb id="\d+?-(\d+?-)?\d+?[abcd]?"\/>$/mg,
|
|
37
37
|
suspectedRegex: /<pb /g,
|
|
38
38
|
tagNameStrRegex: /pb/g,
|
|
39
|
-
lineWithTagRegex: /^.*?pb
|
|
39
|
+
lineWithTagRegex: /^.*?pb.*$/mg
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
type: 'jp',
|
|
43
43
|
correctRegex: /<jp id="\d+?-\d+?-\d+?[abcd]"\/>/g,
|
|
44
44
|
suspectedRegex: /<jp /g,
|
|
45
45
|
tagNameStrRegex: /jp/g,
|
|
46
|
-
lineWithTagRegex: /^.*?jp
|
|
46
|
+
lineWithTagRegex: /^.*?jp.*$/mg
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
49
|
type: 'division',
|
|
50
50
|
correctRegex: new RegExp('<division n="(\\d+?)" t="[^"<>\n]+?"( (bo|en|tw|cn)="[^"<>\n]+?")*? i18n="' + repo + '-division-\\1"\\/>', 'g'),
|
|
51
51
|
suspectedRegex: /<division /g,
|
|
52
52
|
tagNameStrRegex: /division/g,
|
|
53
|
-
lineWithTagRegex: /^.*?division
|
|
53
|
+
lineWithTagRegex: /^.*?division.*$/mg
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
type: 'vol',
|
|
57
57
|
correctRegex: /<vol n="\d+?(-\d+?)?"( (t|bo|en|tw|cn)="[^"<>\n]*?")+?\/>/g,
|
|
58
58
|
suspectedRegex: /<vol /g,
|
|
59
59
|
tagNameStrRegex: /vol(?!text|cover|toc)/g,
|
|
60
|
-
lineWithTagRegex: /^.*?vol
|
|
60
|
+
lineWithTagRegex: /^.*?vol.*$/mg
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
63
|
type: 'sutra',
|
|
64
64
|
correctRegex: new RegExp(`<sutra id="${sutraV}\\d+?[a-zA-Z]?"( (t|bo|en|tw|cn)="[^"<>\n]*?")*\\/>`, 'g'),
|
|
65
65
|
suspectedRegex: /<sutra /g,
|
|
66
66
|
tagNameStrRegex: /sutra/g,
|
|
67
|
-
lineWithTagRegex: /^.*?sutra
|
|
67
|
+
lineWithTagRegex: /^.*?sutra.*$/mg
|
|
68
68
|
},
|
|
69
69
|
{
|
|
70
70
|
type: 'bampo',
|
|
71
71
|
correctRegex: /<bampo n="\d+?[a-zA-Z]?\.\d+?"( (t|bo|en|tw|cn)="[^"<>\n]*?")*( zh="[^"<>\n]+?")*?\/>/g,
|
|
72
72
|
suspectedRegex: /<bampo /g,
|
|
73
73
|
tagNameStrRegex: /bampo/g,
|
|
74
|
-
lineWithTagRegex: /^.*?bampo
|
|
74
|
+
lineWithTagRegex: /^.*?bampo.*$/mg
|
|
75
75
|
},
|
|
76
76
|
{
|
|
77
77
|
type: 'head',
|
|
78
78
|
correctRegex: /<head n="\d+?" (t|bo|en|tw|cn)="[^"<>\n]*?"( (type|zh|lv|st|ct|tid|sff|bo|en|tw|cn)="[^"<>\n]*?")*?\/>/g,
|
|
79
79
|
suspectedRegex: /<head /g,
|
|
80
80
|
tagNameStrRegex: /head(?!note)/g,
|
|
81
|
-
lineWithTagRegex: /^.*?head
|
|
81
|
+
lineWithTagRegex: /^.*?head.*$/mg
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
84
|
type: 'voltext',
|
|
85
85
|
correctRegex: /<voltext( (t|bo|en|tw|cn|type)="[^"<>\n]*?")*?\/?>|<\/voltext>|<voltext\/>/g,
|
|
86
86
|
suspectedRegex: /<voltext |<\/voltext>|<voltext\/>/g,
|
|
87
87
|
tagNameStrRegex: /voltext/g,
|
|
88
|
-
lineWithTagRegex: /^.*?voltext
|
|
88
|
+
lineWithTagRegex: /^.*?voltext.*$/mg
|
|
89
89
|
}
|
|
90
90
|
];
|
|
91
91
|
|
|
@@ -94,4 +94,4 @@ export default function getTagRules(pbWithSuffix) {
|
|
|
94
94
|
tagRules[0].correctRegex = /<(pb|jp) id="\d+?-(\d+?-)?\d+?"\/>/g;
|
|
95
95
|
}
|
|
96
96
|
return tagRules;
|
|
97
|
-
}
|
|
97
|
+
}
|