wikilint 2.11.0 → 2.12.2
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/config/.schema.json +24 -7
- package/config/default.json +30 -29
- package/config/enwiki.json +15 -14
- package/config/llwiki.json +21 -20
- package/config/moegirl.json +21 -20
- package/config/zhwiki.json +28 -27
- package/dist/base.d.ts +1 -1
- package/dist/index.js +16 -1
- package/dist/lib/node.js +1 -1
- package/dist/lib/text.js +1 -0
- package/dist/lib/title.d.ts +6 -2
- package/dist/lib/title.js +30 -13
- package/dist/parser/braces.js +4 -4
- package/dist/parser/commentAndExt.js +6 -3
- package/dist/parser/converter.js +1 -1
- package/dist/parser/hrAndDoubleUnderscore.js +6 -6
- package/dist/parser/list.js +1 -1
- package/dist/parser/redirect.js +1 -1
- package/dist/parser/table.js +1 -1
- package/dist/src/arg.js +4 -4
- package/dist/src/attribute.js +2 -2
- package/dist/src/attributes.d.ts +2 -1
- package/dist/src/attributes.js +4 -5
- package/dist/src/converterFlags.js +3 -3
- package/dist/src/extLink.js +1 -1
- package/dist/src/gallery.js +2 -2
- package/dist/src/heading.d.ts +2 -0
- package/dist/src/heading.js +2 -2
- package/dist/src/html.js +1 -1
- package/dist/src/imageParameter.js +1 -1
- package/dist/src/imagemap.js +1 -1
- package/dist/src/imagemapLink.d.ts +3 -1
- package/dist/src/index.js +5 -3
- package/dist/src/magicLink.js +7 -5
- package/dist/src/nested.js +2 -2
- package/dist/src/nowiki/doubleUnderscore.d.ts +2 -2
- package/dist/src/nowiki/doubleUnderscore.js +2 -1
- package/dist/src/parameter.js +2 -1
- package/dist/src/pre.js +1 -1
- package/dist/src/table/index.js +2 -3
- package/dist/src/table/td.js +1 -1
- package/dist/src/tagPair/ext.js +18 -24
- package/dist/src/transclude.js +4 -5
- package/dist/util/string.js +7 -7
- package/package.json +3 -15
package/config/.schema.json
CHANGED
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"parserFunction": {
|
|
47
47
|
"type": "array",
|
|
48
|
-
"
|
|
48
|
+
"prefixItems": [
|
|
49
49
|
{
|
|
50
50
|
"description": "case-insensitive parser functions",
|
|
51
51
|
"type": "object",
|
|
@@ -93,14 +93,31 @@
|
|
|
93
93
|
"doubleUnderscore": {
|
|
94
94
|
"description": "behavior switches",
|
|
95
95
|
"type": "array",
|
|
96
|
-
"
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
"type": "
|
|
96
|
+
"prefixItems": [
|
|
97
|
+
{
|
|
98
|
+
"description": "case-insensitive behavior switches",
|
|
99
|
+
"type": "array",
|
|
100
|
+
"items": {
|
|
101
|
+
"type": "string"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"description": "case-sensitive behavior switches",
|
|
106
|
+
"type": "array",
|
|
107
|
+
"items": {
|
|
108
|
+
"type": "string"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"description": "case-insensitive behavior switches",
|
|
113
|
+
"type": "object",
|
|
114
|
+
"additionalProperties": {
|
|
115
|
+
"type": "string"
|
|
116
|
+
}
|
|
100
117
|
}
|
|
101
|
-
|
|
118
|
+
],
|
|
102
119
|
"minItems": 2,
|
|
103
|
-
"maxItems":
|
|
120
|
+
"maxItems": 3
|
|
104
121
|
},
|
|
105
122
|
"protocol": {
|
|
106
123
|
"description": "external link protocols",
|
package/config/default.json
CHANGED
|
@@ -717,34 +717,7 @@
|
|
|
717
717
|
]
|
|
718
718
|
],
|
|
719
719
|
"doubleUnderscore": [
|
|
720
|
-
[
|
|
721
|
-
"forcetoc",
|
|
722
|
-
"强显目录",
|
|
723
|
-
"強制目錄",
|
|
724
|
-
"nocc",
|
|
725
|
-
"nocontentconvert",
|
|
726
|
-
"不转换内容",
|
|
727
|
-
"不轉換內容",
|
|
728
|
-
"noeditsection",
|
|
729
|
-
"无段落编辑",
|
|
730
|
-
"无编辑段落",
|
|
731
|
-
"無段落編輯",
|
|
732
|
-
"nogallery",
|
|
733
|
-
"无图库",
|
|
734
|
-
"無圖庫",
|
|
735
|
-
"notc",
|
|
736
|
-
"notitleconvert",
|
|
737
|
-
"不转换标题",
|
|
738
|
-
"不轉換標題",
|
|
739
|
-
"notoc",
|
|
740
|
-
"无目录",
|
|
741
|
-
"無目錄",
|
|
742
|
-
"toc",
|
|
743
|
-
"目录",
|
|
744
|
-
"目錄",
|
|
745
|
-
"archivedtalk",
|
|
746
|
-
"notalk"
|
|
747
|
-
],
|
|
720
|
+
[],
|
|
748
721
|
[
|
|
749
722
|
"EXPECTUNUSEDCATEGORY",
|
|
750
723
|
"DISAMBIG",
|
|
@@ -765,7 +738,35 @@
|
|
|
765
738
|
"靜態重新導向",
|
|
766
739
|
"NOGLOBAL",
|
|
767
740
|
"EXPECTED_UNCONNECTED_PAGE"
|
|
768
|
-
]
|
|
741
|
+
],
|
|
742
|
+
{
|
|
743
|
+
"forcetoc": "forcetoc",
|
|
744
|
+
"强显目录": "forcetoc",
|
|
745
|
+
"強制目錄": "forcetoc",
|
|
746
|
+
"nocc": "nocontentconvert",
|
|
747
|
+
"nocontentconvert": "nocontentconvert",
|
|
748
|
+
"不转换内容": "nocontentconvert",
|
|
749
|
+
"不轉換內容": "nocontentconvert",
|
|
750
|
+
"noeditsection": "noeditsection",
|
|
751
|
+
"无段落编辑": "noeditsection",
|
|
752
|
+
"无编辑段落": "noeditsection",
|
|
753
|
+
"無段落編輯": "noeditsection",
|
|
754
|
+
"nogallery": "nogallery",
|
|
755
|
+
"无图库": "nogallery",
|
|
756
|
+
"無圖庫": "nogallery",
|
|
757
|
+
"notc": "notitleconvert",
|
|
758
|
+
"notitleconvert": "notitleconvert",
|
|
759
|
+
"不转换标题": "notitleconvert",
|
|
760
|
+
"不轉換標題": "notitleconvert",
|
|
761
|
+
"notoc": "notoc",
|
|
762
|
+
"无目录": "notoc",
|
|
763
|
+
"無目錄": "notoc",
|
|
764
|
+
"toc": "toc",
|
|
765
|
+
"目录": "toc",
|
|
766
|
+
"目錄": "toc",
|
|
767
|
+
"archivedtalk": "archivedtalk",
|
|
768
|
+
"notalk": "notalk"
|
|
769
|
+
}
|
|
769
770
|
],
|
|
770
771
|
"protocol": "bitcoin:|ftp://|ftps://|geo:|git://|gopher://|http://|https://|irc://|ircs://|magnet:|mailto:|matrix:|mms://|news:|nntp://|redis://|sftp://|sip:|sips:|sms:|ssh://|svn://|tel:|telnet://|urn:|worldwind://|xmpp:",
|
|
771
772
|
"interwiki": [],
|
package/config/enwiki.json
CHANGED
|
@@ -343,19 +343,7 @@
|
|
|
343
343
|
]
|
|
344
344
|
],
|
|
345
345
|
"doubleUnderscore": [
|
|
346
|
-
[
|
|
347
|
-
"forcetoc",
|
|
348
|
-
"nocc",
|
|
349
|
-
"nocontentconvert",
|
|
350
|
-
"noeditsection",
|
|
351
|
-
"nogallery",
|
|
352
|
-
"notc",
|
|
353
|
-
"notitleconvert",
|
|
354
|
-
"notoc",
|
|
355
|
-
"toc",
|
|
356
|
-
"archivedtalk",
|
|
357
|
-
"notalk"
|
|
358
|
-
],
|
|
346
|
+
[],
|
|
359
347
|
[
|
|
360
348
|
"EXPECTUNUSEDCATEGORY",
|
|
361
349
|
"DISAMBIG",
|
|
@@ -367,7 +355,20 @@
|
|
|
367
355
|
"STATICREDIRECT",
|
|
368
356
|
"NOGLOBAL",
|
|
369
357
|
"EXPECTED_UNCONNECTED_PAGE"
|
|
370
|
-
]
|
|
358
|
+
],
|
|
359
|
+
{
|
|
360
|
+
"forcetoc": "forcetoc",
|
|
361
|
+
"nocc": "nocontentconvert",
|
|
362
|
+
"nocontentconvert": "nocontentconvert",
|
|
363
|
+
"noeditsection": "noeditsection",
|
|
364
|
+
"nogallery": "nogallery",
|
|
365
|
+
"notc": "notitleconvert",
|
|
366
|
+
"notitleconvert": "notitleconvert",
|
|
367
|
+
"notoc": "notoc",
|
|
368
|
+
"toc": "toc",
|
|
369
|
+
"archivedtalk": "archivedtalk",
|
|
370
|
+
"notalk": "notalk"
|
|
371
|
+
}
|
|
371
372
|
],
|
|
372
373
|
"protocol": "bitcoin:|ftp://|ftps://|geo:|git://|gopher://|http://|https://|irc://|ircs://|magnet:|mailto:|matrix:|mms://|news:|nntp://|redis://|sftp://|sip:|sips:|sms:|ssh://|svn://|tel:|telnet://|urn:|worldwind://|xmpp:",
|
|
373
374
|
"interwiki": [],
|
package/config/llwiki.json
CHANGED
|
@@ -483,25 +483,7 @@
|
|
|
483
483
|
]
|
|
484
484
|
],
|
|
485
485
|
"doubleUnderscore": [
|
|
486
|
-
[
|
|
487
|
-
"forcetoc",
|
|
488
|
-
"强显目录",
|
|
489
|
-
"nocc",
|
|
490
|
-
"nocontentconvert",
|
|
491
|
-
"不转换内容",
|
|
492
|
-
"noeditsection",
|
|
493
|
-
"无段落编辑",
|
|
494
|
-
"无编辑段落",
|
|
495
|
-
"nogallery",
|
|
496
|
-
"无图库",
|
|
497
|
-
"notc",
|
|
498
|
-
"notitleconvert",
|
|
499
|
-
"不转换标题",
|
|
500
|
-
"notoc",
|
|
501
|
-
"无目录",
|
|
502
|
-
"toc",
|
|
503
|
-
"目录"
|
|
504
|
-
],
|
|
486
|
+
[],
|
|
505
487
|
[
|
|
506
488
|
"EXPECTUNUSEDCATEGORY",
|
|
507
489
|
"HIDDENCAT",
|
|
@@ -516,7 +498,26 @@
|
|
|
516
498
|
"无新段落链接",
|
|
517
499
|
"STATICREDIRECT",
|
|
518
500
|
"静态重定向"
|
|
519
|
-
]
|
|
501
|
+
],
|
|
502
|
+
{
|
|
503
|
+
"forcetoc": "forcetoc",
|
|
504
|
+
"强显目录": "forcetoc",
|
|
505
|
+
"nocc": "nocontentconvert",
|
|
506
|
+
"nocontentconvert": "nocontentconvert",
|
|
507
|
+
"不转换内容": "nocontentconvert",
|
|
508
|
+
"noeditsection": "noeditsection",
|
|
509
|
+
"无段落编辑": "noeditsection",
|
|
510
|
+
"无编辑段落": "noeditsection",
|
|
511
|
+
"nogallery": "nogallery",
|
|
512
|
+
"无图库": "nogallery",
|
|
513
|
+
"notc": "notitleconvert",
|
|
514
|
+
"notitleconvert": "notitleconvert",
|
|
515
|
+
"不转换标题": "notitleconvert",
|
|
516
|
+
"notoc": "notoc",
|
|
517
|
+
"无目录": "notoc",
|
|
518
|
+
"toc": "toc",
|
|
519
|
+
"目录": "toc"
|
|
520
|
+
}
|
|
520
521
|
],
|
|
521
522
|
"protocol": "bitcoin:|ftp://|ftps://|geo:|git://|gopher://|http://|https://|irc://|ircs://|magnet:|mailto:|matrix:|mms://|news:|nntp://|redis://|sftp://|sip:|sips:|sms:|ssh://|svn://|tel:|telnet://|urn:|worldwind://|xmpp:",
|
|
522
523
|
"interwiki": [],
|
package/config/moegirl.json
CHANGED
|
@@ -575,25 +575,7 @@
|
|
|
575
575
|
]
|
|
576
576
|
],
|
|
577
577
|
"doubleUnderscore": [
|
|
578
|
-
[
|
|
579
|
-
"forcetoc",
|
|
580
|
-
"强显目录",
|
|
581
|
-
"nocc",
|
|
582
|
-
"nocontentconvert",
|
|
583
|
-
"不转换内容",
|
|
584
|
-
"noeditsection",
|
|
585
|
-
"无段落编辑",
|
|
586
|
-
"无编辑段落",
|
|
587
|
-
"nogallery",
|
|
588
|
-
"无图库",
|
|
589
|
-
"notc",
|
|
590
|
-
"notitleconvert",
|
|
591
|
-
"不转换标题",
|
|
592
|
-
"notoc",
|
|
593
|
-
"无目录",
|
|
594
|
-
"toc",
|
|
595
|
-
"目录"
|
|
596
|
-
],
|
|
578
|
+
[],
|
|
597
579
|
[
|
|
598
580
|
"DISAMBIG",
|
|
599
581
|
"消除歧义",
|
|
@@ -609,7 +591,26 @@
|
|
|
609
591
|
"无新段落链接",
|
|
610
592
|
"STATICREDIRECT",
|
|
611
593
|
"静态重定向"
|
|
612
|
-
]
|
|
594
|
+
],
|
|
595
|
+
{
|
|
596
|
+
"forcetoc": "forcetoc",
|
|
597
|
+
"强显目录": "forcetoc",
|
|
598
|
+
"nocc": "nocontentconvert",
|
|
599
|
+
"nocontentconvert": "nocontentconvert",
|
|
600
|
+
"不转换内容": "nocontentconvert",
|
|
601
|
+
"noeditsection": "noeditsection",
|
|
602
|
+
"无段落编辑": "noeditsection",
|
|
603
|
+
"无编辑段落": "noeditsection",
|
|
604
|
+
"nogallery": "nogallery",
|
|
605
|
+
"无图库": "nogallery",
|
|
606
|
+
"notc": "notitleconvert",
|
|
607
|
+
"notitleconvert": "notitleconvert",
|
|
608
|
+
"不转换标题": "notitleconvert",
|
|
609
|
+
"notoc": "notoc",
|
|
610
|
+
"无目录": "notoc",
|
|
611
|
+
"toc": "toc",
|
|
612
|
+
"目录": "toc"
|
|
613
|
+
}
|
|
613
614
|
],
|
|
614
615
|
"protocol": "bitcoin:|ftp://|ftps://|geo:|git://|gopher://|http://|https://|irc://|ircs://|magnet:|mailto:|mms://|news:|nntp://|redis://|sftp://|sip:|sips:|sms:|ssh://|svn://|tel:|telnet://|urn:|worldwind://|xmpp:",
|
|
615
616
|
"interwiki": [],
|
package/config/zhwiki.json
CHANGED
|
@@ -659,32 +659,7 @@
|
|
|
659
659
|
]
|
|
660
660
|
],
|
|
661
661
|
"doubleUnderscore": [
|
|
662
|
-
[
|
|
663
|
-
"forcetoc",
|
|
664
|
-
"强显目录",
|
|
665
|
-
"強制目錄",
|
|
666
|
-
"nocc",
|
|
667
|
-
"nocontentconvert",
|
|
668
|
-
"不转换内容",
|
|
669
|
-
"不轉換內容",
|
|
670
|
-
"noeditsection",
|
|
671
|
-
"无段落编辑",
|
|
672
|
-
"无编辑段落",
|
|
673
|
-
"無段落編輯",
|
|
674
|
-
"nogallery",
|
|
675
|
-
"无图库",
|
|
676
|
-
"無圖庫",
|
|
677
|
-
"notc",
|
|
678
|
-
"notitleconvert",
|
|
679
|
-
"不转换标题",
|
|
680
|
-
"不轉換標題",
|
|
681
|
-
"notoc",
|
|
682
|
-
"无目录",
|
|
683
|
-
"無目錄",
|
|
684
|
-
"toc",
|
|
685
|
-
"目录",
|
|
686
|
-
"目錄"
|
|
687
|
-
],
|
|
662
|
+
[],
|
|
688
663
|
[
|
|
689
664
|
"EXPECTUNUSEDCATEGORY",
|
|
690
665
|
"DISAMBIG",
|
|
@@ -705,7 +680,33 @@
|
|
|
705
680
|
"靜態重新導向",
|
|
706
681
|
"NOGLOBAL",
|
|
707
682
|
"EXPECTED_UNCONNECTED_PAGE"
|
|
708
|
-
]
|
|
683
|
+
],
|
|
684
|
+
{
|
|
685
|
+
"forcetoc": "forcetoc",
|
|
686
|
+
"强显目录": "forcetoc",
|
|
687
|
+
"強制目錄": "forcetoc",
|
|
688
|
+
"nocc": "nocontentconvert",
|
|
689
|
+
"nocontentconvert": "nocontentconvert",
|
|
690
|
+
"不转换内容": "nocontentconvert",
|
|
691
|
+
"不轉換內容": "nocontentconvert",
|
|
692
|
+
"noeditsection": "noeditsection",
|
|
693
|
+
"无段落编辑": "noeditsection",
|
|
694
|
+
"无编辑段落": "noeditsection",
|
|
695
|
+
"無段落編輯": "noeditsection",
|
|
696
|
+
"nogallery": "nogallery",
|
|
697
|
+
"无图库": "nogallery",
|
|
698
|
+
"無圖庫": "nogallery",
|
|
699
|
+
"notc": "notitleconvert",
|
|
700
|
+
"notitleconvert": "notitleconvert",
|
|
701
|
+
"不转换标题": "notitleconvert",
|
|
702
|
+
"不轉換標題": "notitleconvert",
|
|
703
|
+
"notoc": "notoc",
|
|
704
|
+
"无目录": "notoc",
|
|
705
|
+
"無目錄": "notoc",
|
|
706
|
+
"toc": "toc",
|
|
707
|
+
"目录": "toc",
|
|
708
|
+
"目錄": "toc"
|
|
709
|
+
}
|
|
709
710
|
],
|
|
710
711
|
"protocol": "bitcoin:|ftp://|ftps://|geo:|git://|gopher://|http://|https://|irc://|ircs://|magnet:|mailto:|matrix:|mms://|news:|nntp://|redis://|sftp://|sip:|sips:|sms:|ssh://|svn://|tel:|telnet://|urn:|worldwind://|xmpp:",
|
|
711
712
|
"interwiki": [],
|
package/dist/base.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface Config {
|
|
|
4
4
|
readonly namespaces: Record<string, string>;
|
|
5
5
|
readonly nsid: Record<string, number>;
|
|
6
6
|
readonly parserFunction: [Record<string, string>, string[], string[], string[]];
|
|
7
|
-
readonly doubleUnderscore: [string[], string[]];
|
|
7
|
+
readonly doubleUnderscore: [string[], string[], Record<string, string>?];
|
|
8
8
|
readonly protocol: string;
|
|
9
9
|
readonly img: Record<string, string>;
|
|
10
10
|
readonly redirection: string[];
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,8 @@ const base_1 = require("./base");
|
|
|
6
6
|
const debug_1 = require("./util/debug");
|
|
7
7
|
const constants_1 = require("./util/constants");
|
|
8
8
|
const string_1 = require("./util/string");
|
|
9
|
+
/* NOT FOR BROWSER */
|
|
10
|
+
const diff_1 = require("./util/diff");
|
|
9
11
|
/**
|
|
10
12
|
* 从根路径require
|
|
11
13
|
* @param file 文件名
|
|
@@ -22,6 +24,13 @@ const Parser = {
|
|
|
22
24
|
this.config = rootRequire(this.config, 'config');
|
|
23
25
|
return this.getConfig();
|
|
24
26
|
}
|
|
27
|
+
const { doubleUnderscore } = this.config;
|
|
28
|
+
if (doubleUnderscore.length === 2) {
|
|
29
|
+
(0, diff_1.error)(`The schema (${path.resolve(__dirname, '..', 'config', '.schema.json')}) of parser configuration is updated.`);
|
|
30
|
+
}
|
|
31
|
+
else if (doubleUnderscore[0].length === 0) {
|
|
32
|
+
doubleUnderscore[0] = Object.keys(doubleUnderscore[2]);
|
|
33
|
+
}
|
|
25
34
|
return {
|
|
26
35
|
...this.config,
|
|
27
36
|
excludes: [],
|
|
@@ -52,7 +61,13 @@ const Parser = {
|
|
|
52
61
|
for (const key of ['main', 'fragment']) {
|
|
53
62
|
const str = t[key];
|
|
54
63
|
if (str?.includes('\0')) {
|
|
55
|
-
|
|
64
|
+
const s = root.buildFromStr(str, constants_1.BuildMethod.Text);
|
|
65
|
+
if (key === 'main') {
|
|
66
|
+
t.main = s;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
t.setFragment(s);
|
|
70
|
+
}
|
|
56
71
|
}
|
|
57
72
|
}
|
|
58
73
|
return t;
|
package/dist/lib/node.js
CHANGED
package/dist/lib/text.js
CHANGED
package/dist/lib/title.d.ts
CHANGED
|
@@ -2,10 +2,12 @@ import type { Config } from '../base';
|
|
|
2
2
|
/** MediaWiki页面标题对象 */
|
|
3
3
|
export declare class Title {
|
|
4
4
|
#private;
|
|
5
|
-
ns: number;
|
|
6
|
-
fragment: string | undefined;
|
|
7
5
|
interwiki: string;
|
|
8
6
|
readonly valid: boolean;
|
|
7
|
+
/** 命名空间 */
|
|
8
|
+
get ns(): number;
|
|
9
|
+
/** 片段标识符 */
|
|
10
|
+
get fragment(): string | undefined;
|
|
9
11
|
/** 不含命名空间的标题主体部分 */
|
|
10
12
|
get main(): string;
|
|
11
13
|
set main(title: string);
|
|
@@ -24,4 +26,6 @@ export declare class Title {
|
|
|
24
26
|
* @param selfLink 是否允许selfLink
|
|
25
27
|
*/
|
|
26
28
|
constructor(title: string, defaultNs: number, config: Config, decode: boolean, selfLink: boolean);
|
|
29
|
+
/** 检测是否是重定向 */
|
|
30
|
+
getRedirection(): [boolean, string];
|
|
27
31
|
}
|
package/dist/lib/title.js
CHANGED
|
@@ -6,12 +6,20 @@ const string_1 = require("../util/string");
|
|
|
6
6
|
class Title {
|
|
7
7
|
#main;
|
|
8
8
|
#namespaces;
|
|
9
|
-
ns;
|
|
10
|
-
fragment;
|
|
9
|
+
#ns;
|
|
10
|
+
#fragment;
|
|
11
11
|
interwiki = '';
|
|
12
12
|
valid;
|
|
13
13
|
/** @private */
|
|
14
14
|
encoded = false;
|
|
15
|
+
/** 命名空间 */
|
|
16
|
+
get ns() {
|
|
17
|
+
return this.#ns;
|
|
18
|
+
}
|
|
19
|
+
/** 片段标识符 */
|
|
20
|
+
get fragment() {
|
|
21
|
+
return this.#fragment;
|
|
22
|
+
}
|
|
15
23
|
/** 不含命名空间的标题主体部分 */
|
|
16
24
|
get main() {
|
|
17
25
|
return this.#main;
|
|
@@ -27,10 +35,7 @@ class Title {
|
|
|
27
35
|
}
|
|
28
36
|
/** 完整标题 */
|
|
29
37
|
get title() {
|
|
30
|
-
|
|
31
|
-
// eslint-disable-next-line prefer-const
|
|
32
|
-
let title = (prefix + this.main).replace(/ /gu, '_');
|
|
33
|
-
return title;
|
|
38
|
+
return this.getRedirection()[1];
|
|
34
39
|
}
|
|
35
40
|
/** 扩展名 */
|
|
36
41
|
get extension() {
|
|
@@ -58,7 +63,7 @@ class Title {
|
|
|
58
63
|
}
|
|
59
64
|
title = title.replace(/[_ ]+/gu, ' ').trim();
|
|
60
65
|
if (subpage) {
|
|
61
|
-
this
|
|
66
|
+
this.#ns = 0;
|
|
62
67
|
}
|
|
63
68
|
else {
|
|
64
69
|
let ns = defaultNs;
|
|
@@ -74,7 +79,7 @@ class Title {
|
|
|
74
79
|
title = m.slice(1).join(':').trim();
|
|
75
80
|
}
|
|
76
81
|
}
|
|
77
|
-
this
|
|
82
|
+
this.#ns = ns;
|
|
78
83
|
}
|
|
79
84
|
const i = title.indexOf('#');
|
|
80
85
|
if (i !== -1) {
|
|
@@ -85,10 +90,11 @@ class Title {
|
|
|
85
90
|
}
|
|
86
91
|
catch { }
|
|
87
92
|
}
|
|
88
|
-
this
|
|
93
|
+
this.#fragment = fragment.replace(/ /gu, '_');
|
|
89
94
|
title = title.slice(0, i).trim();
|
|
90
95
|
}
|
|
91
|
-
this.valid = Boolean(title || this.interwiki || selfLink && this.ns === 0 && this
|
|
96
|
+
this.valid = Boolean(title || this.interwiki || selfLink && this.ns === 0 && this.#fragment !== undefined)
|
|
97
|
+
&& (0, string_1.decodeHtml)(title) === title
|
|
92
98
|
&& !/^:|\0\d+[eh!+-]\x7F|[<>[\]{}|\n]|%[\da-f]{2}|(?:^|\/)\.{1,2}(?:$|\/)/iu.test(subpage ? /^(?:\.\.\/)+(.*)/u.exec(title)[1] : title);
|
|
93
99
|
this.main = title;
|
|
94
100
|
Object.defineProperties(this, {
|
|
@@ -97,10 +103,21 @@ class Title {
|
|
|
97
103
|
this.#namespaces = config.namespaces;
|
|
98
104
|
}
|
|
99
105
|
/** @private */
|
|
100
|
-
toString() {
|
|
101
|
-
return `${this.title}${this
|
|
106
|
+
toString(display) {
|
|
107
|
+
return `${display ? this.title.replace(/_/gu, ' ') : this.title}${this.#fragment === undefined
|
|
102
108
|
? ''
|
|
103
|
-
: `#${this
|
|
109
|
+
: `#${this.#fragment}`}`;
|
|
110
|
+
}
|
|
111
|
+
/** 检测是否是重定向 */
|
|
112
|
+
getRedirection() {
|
|
113
|
+
const prefix = this.interwiki + (this.interwiki && ':') + this.prefix;
|
|
114
|
+
// eslint-disable-next-line prefer-const
|
|
115
|
+
let title = (prefix + this.main).replace(/ /gu, '_');
|
|
116
|
+
return [false, title];
|
|
117
|
+
}
|
|
118
|
+
/** @private */
|
|
119
|
+
setFragment(fragment) {
|
|
120
|
+
this.#fragment = fragment;
|
|
104
121
|
}
|
|
105
122
|
}
|
|
106
123
|
exports.Title = Title;
|
package/dist/parser/braces.js
CHANGED
|
@@ -6,7 +6,7 @@ const heading_1 = require("../src/heading");
|
|
|
6
6
|
const transclude_1 = require("../src/transclude");
|
|
7
7
|
const arg_1 = require("../src/arg");
|
|
8
8
|
const closes = {
|
|
9
|
-
'=':
|
|
9
|
+
'=': String.raw `\n(?!(?:[^\S\n]|\0\d+[cn]\x7F)*\n)`,
|
|
10
10
|
'{': String.raw `\}{2,}|\|`,
|
|
11
11
|
'-': String.raw `\}-`,
|
|
12
12
|
'[': String.raw `\]\]`,
|
|
@@ -19,7 +19,7 @@ const closes = {
|
|
|
19
19
|
* @throws TranscludeToken.constructor()
|
|
20
20
|
*/
|
|
21
21
|
const parseBraces = (wikitext, config, accum) => {
|
|
22
|
-
const source = String.raw `${config.excludes?.includes('heading') ? '' : String.raw `^(
|
|
22
|
+
const source = String.raw `${config.excludes?.includes('heading') ? '' : String.raw `^((?:\0\d+[cno]\x7F)*)={1,6}|`}\[\[|-\{(?!\{)`, openBraces = String.raw `|\{{2,}`, { parserFunction: [, , , subst] } = config, stack = [];
|
|
23
23
|
wikitext = wikitext.replace(re, (m, p1) => {
|
|
24
24
|
// @ts-expect-error abstract class
|
|
25
25
|
new transclude_1.TranscludeToken(m.slice(2, -2), [], config, accum);
|
|
@@ -49,7 +49,7 @@ const parseBraces = (wikitext, config, accum) => {
|
|
|
49
49
|
lastIndex = curIndex + 1;
|
|
50
50
|
const { pos, findEqual } = stack[stack.length - 1] ?? {};
|
|
51
51
|
if (pos === undefined || findEqual || (0, string_1.removeComment)(wikitext.slice(pos, index)) !== '') {
|
|
52
|
-
const rmt = /^(={1,6})(.+)\1((?:\s|\0\d+
|
|
52
|
+
const rmt = /^(={1,6})(.+)\1((?:\s|\0\d+[cn]\x7F)*)$/u
|
|
53
53
|
.exec(wikitext.slice(index, curIndex));
|
|
54
54
|
if (rmt) {
|
|
55
55
|
wikitext = `${wikitext.slice(0, index)}\0${accum.length}h\x7F${wikitext.slice(curIndex)}`;
|
|
@@ -94,7 +94,7 @@ const parseBraces = (wikitext, config, accum) => {
|
|
|
94
94
|
ch = 'm';
|
|
95
95
|
}
|
|
96
96
|
else if (/^#vardefine:./iu.test(name)) {
|
|
97
|
-
ch = '
|
|
97
|
+
ch = 'n';
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
catch (e) {
|
|
@@ -31,7 +31,7 @@ const parseCommentAndExt = (wikitext, config, accum, includeOnly) => {
|
|
|
31
31
|
const noinclude = (text) => {
|
|
32
32
|
// @ts-expect-error abstract class
|
|
33
33
|
new noinclude_1.NoincludeToken(text, config, accum);
|
|
34
|
-
str += `\0${accum.length - 1}
|
|
34
|
+
str += `\0${accum.length - 1}n\x7F`;
|
|
35
35
|
};
|
|
36
36
|
while (i !== -1 && j !== -1) {
|
|
37
37
|
const token = `\0${accum.length}e\x7F`;
|
|
@@ -51,12 +51,15 @@ const parseCommentAndExt = (wikitext, config, accum, includeOnly) => {
|
|
|
51
51
|
}
|
|
52
52
|
const ext = config.ext.join('|'), noincludeRegex = includeOnly ? 'includeonly' : '(?:no|only)include', includeRegex = includeOnly ? 'noinclude' : 'includeonly', regex = new RegExp(String.raw `<!--.*?(?:-->|$)|<${noincludeRegex}(?:\s[^>]*)?/?>|</${noincludeRegex}\s*>|<(${ext})(\s[^>]*?)?(?:/>|>(.*?)</(\1\s*)>)|<(${includeRegex})(\s[^>]*?)?(?:/>|>(.*?)(?:</(${includeRegex}\s*)>|$))`, 'gisu');
|
|
53
53
|
return wikitext.replace(regex, (substr, name, attr, inner, closing, include, includeAttr, includeInner, includeClosing) => {
|
|
54
|
-
const
|
|
54
|
+
const l = accum.length;
|
|
55
|
+
let ch = 'n';
|
|
55
56
|
if (name) {
|
|
57
|
+
ch = 'e';
|
|
56
58
|
// @ts-expect-error abstract class
|
|
57
59
|
new ext_1.ExtToken(name, attr, inner, closing, config, accum);
|
|
58
60
|
}
|
|
59
61
|
else if (substr.startsWith('<!--')) {
|
|
62
|
+
ch = 'c';
|
|
60
63
|
const closed = substr.endsWith('-->');
|
|
61
64
|
// @ts-expect-error abstract class
|
|
62
65
|
new comment_1.CommentToken(substr.slice(4, closed ? -3 : undefined), closed, config, accum);
|
|
@@ -69,7 +72,7 @@ const parseCommentAndExt = (wikitext, config, accum, includeOnly) => {
|
|
|
69
72
|
// @ts-expect-error abstract class
|
|
70
73
|
new noinclude_1.NoincludeToken(substr, config, accum);
|
|
71
74
|
}
|
|
72
|
-
return
|
|
75
|
+
return `\0${l}${ch}\x7F`;
|
|
73
76
|
});
|
|
74
77
|
};
|
|
75
78
|
exports.parseCommentAndExt = parseCommentAndExt;
|
package/dist/parser/converter.js
CHANGED
|
@@ -9,7 +9,7 @@ const converter_1 = require("../src/converter");
|
|
|
9
9
|
* @param accum
|
|
10
10
|
*/
|
|
11
11
|
const parseConverter = (text, config, accum) => {
|
|
12
|
-
const variants = `(?:${config.variants.join('|')})`, regex1 = /-\{/gu, regex2 = /-\{|\}-/gu, regex3 = new RegExp(String.raw `;(?=(?:[^;]*?=>)?\s*${variants}\s*:|(?:\s|\0\d+
|
|
12
|
+
const variants = `(?:${config.variants.join('|')})`, regex1 = /-\{/gu, regex2 = /-\{|\}-/gu, regex3 = new RegExp(String.raw `;(?=(?:[^;]*?=>)?\s*${variants}\s*:|(?:\s|\0\d+[cn]\x7F)*$)`, 'u'), stack = [];
|
|
13
13
|
let regex = regex1, mt = regex.exec(text);
|
|
14
14
|
while (mt) {
|
|
15
15
|
const { 0: syntax, index } = mt;
|
|
@@ -15,19 +15,19 @@ const parseHrAndDoubleUnderscore = ({ firstChild: { data }, type, name }, config
|
|
|
15
15
|
if (type !== 'root' && (type !== 'ext-inner' || name !== 'poem')) {
|
|
16
16
|
data = `\0${data}`;
|
|
17
17
|
}
|
|
18
|
-
data = data.replace(/^((?:\0\d+
|
|
18
|
+
data = data.replace(/^((?:\0\d+[cno]\x7F)*)(-{4,})/gmu, (_, lead, m) => {
|
|
19
19
|
// @ts-expect-error abstract class
|
|
20
20
|
new hr_1.HrToken(m, config, accum);
|
|
21
21
|
return `${lead}\0${accum.length - 1}r\x7F`;
|
|
22
|
-
}).replace(new RegExp(`__(${[...
|
|
23
|
-
const caseSensitive = sensitive.has(p1);
|
|
24
|
-
if (caseSensitive ||
|
|
22
|
+
}).replace(new RegExp(`__(${[...insensitive, ...sensitive].join('|')})__`, 'giu'), (m, p1) => {
|
|
23
|
+
const caseSensitive = sensitive.has(p1), lc = p1.toLowerCase(), caseInsensitive = insensitive.has(lc);
|
|
24
|
+
if (caseSensitive || caseInsensitive) {
|
|
25
25
|
// @ts-expect-error abstract class
|
|
26
26
|
new doubleUnderscore_1.DoubleUnderscoreToken(p1, caseSensitive, config, accum);
|
|
27
|
-
return `\0${accum.length - 1}u\x7F`;
|
|
27
|
+
return `\0${accum.length - 1}${caseInsensitive && (doubleUnderscore[2]?.[lc] ?? lc) === 'toc' ? 'u' : 'n'}\x7F`;
|
|
28
28
|
}
|
|
29
29
|
return m;
|
|
30
|
-
}).replace(/^((?:\0\d+
|
|
30
|
+
}).replace(/^((?:\0\d+[cn]\x7F)*)(={1,6})(.+)\2((?:\s|\0\d+[cn]\x7F)*)$/gmu, (_, lead, equals, heading, trail) => {
|
|
31
31
|
const text = `${lead}\0${accum.length}h\x7F`;
|
|
32
32
|
// @ts-expect-error abstract class
|
|
33
33
|
new heading_1.HeadingToken(equals.length, [heading, trail], config, accum);
|
package/dist/parser/list.js
CHANGED
|
@@ -13,7 +13,7 @@ const dd_1 = require("../src/nowiki/dd");
|
|
|
13
13
|
* @param accum
|
|
14
14
|
*/
|
|
15
15
|
const parseList = (wikitext, state, config, accum) => {
|
|
16
|
-
const mt = /^((?:\0\d+
|
|
16
|
+
const mt = /^((?:\0\d+[cno]\x7F)*)([;:*#]+\s*)/u.exec(wikitext);
|
|
17
17
|
if (!mt) {
|
|
18
18
|
state.lastPrefix = '';
|
|
19
19
|
return wikitext;
|
package/dist/parser/redirect.js
CHANGED
|
@@ -12,7 +12,7 @@ const redirect_1 = require("../src/redirect");
|
|
|
12
12
|
const parseRedirect = (text, config, accum) => {
|
|
13
13
|
const re = new RegExp(String.raw `^(\s*)((?:${config.redirection.join('|')})\s*(?::\s*)?)\[\[([^\n|\]]+)(\|.*?)?\]\](\s*)`, 'iu'), mt = re.exec(text);
|
|
14
14
|
if (mt && index_1.default.normalizeTitle(mt[3], 0, false, config, true, true).valid) {
|
|
15
|
-
text = `\0${accum.length}
|
|
15
|
+
text = `\0${accum.length}o\x7F${text.slice(mt[0].length)}`;
|
|
16
16
|
// @ts-expect-error abstract class
|
|
17
17
|
new redirect_1.RedirectToken(...mt.slice(1), config, accum);
|
|
18
18
|
return text;
|
package/dist/parser/table.js
CHANGED
|
@@ -47,7 +47,7 @@ const parseTable = ({ firstChild: { data }, type, name }, config, accum) => {
|
|
|
47
47
|
pop = () => top.type === 'td' ? stack.pop() : top;
|
|
48
48
|
for (const outLine of lines) {
|
|
49
49
|
top = stack.pop();
|
|
50
|
-
const [spaces] = /^(?:\s|\0\d+
|
|
50
|
+
const [spaces] = /^(?:\s|\0\d+[cno]\x7F)*/u.exec(outLine), line = outLine.slice(spaces.length), matchesStart = /^(:*)((?:\s|\0\d+[cn]\x7F)*)(\{\||\{(?:\0\d+[cn]\x7F)*\0\d+!\x7F|\0\d+\{\x7F)(.*)$/u
|
|
51
51
|
.exec(line);
|
|
52
52
|
if (matchesStart) {
|
|
53
53
|
while (top && top.type !== 'td') {
|