wikilint 2.11.1 → 2.12.4

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.
Files changed (48) hide show
  1. package/config/.schema.json +24 -7
  2. package/config/default.json +34 -30
  3. package/config/enwiki.json +19 -15
  4. package/config/llwiki.json +21 -20
  5. package/config/minimum.json +4 -1
  6. package/config/moegirl.json +21 -20
  7. package/config/zhwiki.json +32 -28
  8. package/dist/base.d.ts +1 -1
  9. package/dist/index.js +16 -1
  10. package/dist/lib/element.js +4 -4
  11. package/dist/lib/text.js +1 -0
  12. package/dist/lib/title.d.ts +6 -2
  13. package/dist/lib/title.js +30 -13
  14. package/dist/parser/braces.js +4 -4
  15. package/dist/parser/commentAndExt.js +6 -3
  16. package/dist/parser/converter.js +1 -1
  17. package/dist/parser/hrAndDoubleUnderscore.js +6 -6
  18. package/dist/parser/list.js +1 -1
  19. package/dist/parser/magicLinks.js +2 -1
  20. package/dist/parser/redirect.js +1 -1
  21. package/dist/parser/table.js +1 -1
  22. package/dist/src/arg.js +4 -4
  23. package/dist/src/attribute.js +2 -2
  24. package/dist/src/attributes.d.ts +2 -1
  25. package/dist/src/attributes.js +4 -5
  26. package/dist/src/converterFlags.js +3 -3
  27. package/dist/src/extLink.js +1 -1
  28. package/dist/src/gallery.js +2 -2
  29. package/dist/src/heading.d.ts +2 -0
  30. package/dist/src/heading.js +3 -3
  31. package/dist/src/html.js +1 -1
  32. package/dist/src/imagemap.js +1 -1
  33. package/dist/src/imagemapLink.d.ts +3 -1
  34. package/dist/src/index.js +30 -17
  35. package/dist/src/magicLink.js +7 -5
  36. package/dist/src/nested.js +2 -2
  37. package/dist/src/nowiki/doubleUnderscore.d.ts +2 -2
  38. package/dist/src/nowiki/doubleUnderscore.js +2 -1
  39. package/dist/src/parameter.js +2 -1
  40. package/dist/src/pre.js +1 -1
  41. package/dist/src/table/index.js +2 -3
  42. package/dist/src/table/td.js +1 -1
  43. package/dist/src/tagPair/ext.js +19 -25
  44. package/dist/src/transclude.js +4 -5
  45. package/dist/util/string.js +7 -7
  46. package/i18n/zh-hans.json +1 -0
  47. package/i18n/zh-hant.json +1 -0
  48. package/package.json +2 -2
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "parserFunction": {
47
47
  "type": "array",
48
- "items": [
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
- "items": {
97
- "type": "array",
98
- "items": {
99
- "type": "string"
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": 2
120
+ "maxItems": 3
104
121
  },
105
122
  "protocol": {
106
123
  "description": "external link protocols",
@@ -702,7 +702,10 @@
702
702
  "CONTENTLANGUAGE",
703
703
  "CONTENTLANG",
704
704
  "PAGELANGUAGE",
705
- "="
705
+ "=",
706
+ "#FORMAL",
707
+ "#timef",
708
+ "#timefl"
706
709
  ],
707
710
  [
708
711
  "msg",
@@ -717,34 +720,7 @@
717
720
  ]
718
721
  ],
719
722
  "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
- ],
723
+ [],
748
724
  [
749
725
  "EXPECTUNUSEDCATEGORY",
750
726
  "DISAMBIG",
@@ -765,7 +741,35 @@
765
741
  "靜態重新導向",
766
742
  "NOGLOBAL",
767
743
  "EXPECTED_UNCONNECTED_PAGE"
768
- ]
744
+ ],
745
+ {
746
+ "forcetoc": "forcetoc",
747
+ "强显目录": "forcetoc",
748
+ "強制目錄": "forcetoc",
749
+ "nocc": "nocontentconvert",
750
+ "nocontentconvert": "nocontentconvert",
751
+ "不转换内容": "nocontentconvert",
752
+ "不轉換內容": "nocontentconvert",
753
+ "noeditsection": "noeditsection",
754
+ "无段落编辑": "noeditsection",
755
+ "无编辑段落": "noeditsection",
756
+ "無段落編輯": "noeditsection",
757
+ "nogallery": "nogallery",
758
+ "无图库": "nogallery",
759
+ "無圖庫": "nogallery",
760
+ "notc": "notitleconvert",
761
+ "notitleconvert": "notitleconvert",
762
+ "不转换标题": "notitleconvert",
763
+ "不轉換標題": "notitleconvert",
764
+ "notoc": "notoc",
765
+ "无目录": "notoc",
766
+ "無目錄": "notoc",
767
+ "toc": "toc",
768
+ "目录": "toc",
769
+ "目錄": "toc",
770
+ "archivedtalk": "archivedtalk",
771
+ "notalk": "notalk"
772
+ }
769
773
  ],
770
774
  "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
775
  "interwiki": [],
@@ -331,7 +331,10 @@
331
331
  "CONTENTLANGUAGE",
332
332
  "CONTENTLANG",
333
333
  "PAGELANGUAGE",
334
- "="
334
+ "=",
335
+ "#FORMAL",
336
+ "#timef",
337
+ "#timefl"
335
338
  ],
336
339
  [
337
340
  "msg",
@@ -343,19 +346,7 @@
343
346
  ]
344
347
  ],
345
348
  "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
- ],
349
+ [],
359
350
  [
360
351
  "EXPECTUNUSEDCATEGORY",
361
352
  "DISAMBIG",
@@ -367,7 +358,20 @@
367
358
  "STATICREDIRECT",
368
359
  "NOGLOBAL",
369
360
  "EXPECTED_UNCONNECTED_PAGE"
370
- ]
361
+ ],
362
+ {
363
+ "forcetoc": "forcetoc",
364
+ "nocc": "nocontentconvert",
365
+ "nocontentconvert": "nocontentconvert",
366
+ "noeditsection": "noeditsection",
367
+ "nogallery": "nogallery",
368
+ "notc": "notitleconvert",
369
+ "notitleconvert": "notitleconvert",
370
+ "notoc": "notoc",
371
+ "toc": "toc",
372
+ "archivedtalk": "archivedtalk",
373
+ "notalk": "notalk"
374
+ }
371
375
  ],
372
376
  "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
377
  "interwiki": [],
@@ -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": [],
@@ -114,7 +114,10 @@
114
114
  },
115
115
  [
116
116
  "!",
117
- "="
117
+ "=",
118
+ "#FORMAL",
119
+ "#timef",
120
+ "#timefl"
118
121
  ],
119
122
  [
120
123
  "msg",
@@ -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": [],
@@ -644,7 +644,10 @@
644
644
  "CONTENTLANGUAGE",
645
645
  "CONTENTLANG",
646
646
  "PAGELANGUAGE",
647
- "="
647
+ "=",
648
+ "#FORMAL",
649
+ "#timef",
650
+ "#timefl"
648
651
  ],
649
652
  [
650
653
  "msg",
@@ -659,32 +662,7 @@
659
662
  ]
660
663
  ],
661
664
  "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
- ],
665
+ [],
688
666
  [
689
667
  "EXPECTUNUSEDCATEGORY",
690
668
  "DISAMBIG",
@@ -705,7 +683,33 @@
705
683
  "靜態重新導向",
706
684
  "NOGLOBAL",
707
685
  "EXPECTED_UNCONNECTED_PAGE"
708
- ]
686
+ ],
687
+ {
688
+ "forcetoc": "forcetoc",
689
+ "强显目录": "forcetoc",
690
+ "強制目錄": "forcetoc",
691
+ "nocc": "nocontentconvert",
692
+ "nocontentconvert": "nocontentconvert",
693
+ "不转换内容": "nocontentconvert",
694
+ "不轉換內容": "nocontentconvert",
695
+ "noeditsection": "noeditsection",
696
+ "无段落编辑": "noeditsection",
697
+ "无编辑段落": "noeditsection",
698
+ "無段落編輯": "noeditsection",
699
+ "nogallery": "nogallery",
700
+ "无图库": "nogallery",
701
+ "無圖庫": "nogallery",
702
+ "notc": "notitleconvert",
703
+ "notitleconvert": "notitleconvert",
704
+ "不转换标题": "notitleconvert",
705
+ "不轉換標題": "notitleconvert",
706
+ "notoc": "notoc",
707
+ "无目录": "notoc",
708
+ "無目錄": "notoc",
709
+ "toc": "toc",
710
+ "目录": "toc",
711
+ "目錄": "toc"
712
+ }
709
713
  ],
710
714
  "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
715
  "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
- t[key] = root.buildFromStr(str, constants_1.BuildMethod.Text);
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;
@@ -8,10 +8,10 @@ const node_1 = require("./node");
8
8
  * 将选择器转化为类型谓词
9
9
  * @param selector 选择器
10
10
  */
11
- const getCondition = (selector) => {
12
- const types = new Set(selector.split(',').map(str => str.trim()));
13
- return (({ type }) => types.has(type));
14
- };
11
+ const getCondition = (selector) => (({ type, name }) => selector.split(',').some(str => {
12
+ const [t, ...ns] = str.trim().split('#');
13
+ return (!t || t === type) && ns.every(n => n === name);
14
+ }));
15
15
  /** 类似HTMLElement */
16
16
  class AstElement extends node_1.AstNode {
17
17
  /** 子节点总数 */
package/dist/lib/text.js CHANGED
@@ -89,6 +89,7 @@ class AstText extends node_1.AstNode {
89
89
  }
90
90
  errorRegex ??= type === 'free-ext-link'
91
91
  || type === 'ext-link-url'
92
+ || type === 'ext-link-text'
92
93
  || type === 'image-parameter' && name === 'link'
93
94
  || isHtmlAttrVal
94
95
  ? errorSyntaxUrl
@@ -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
- const prefix = this.interwiki + (this.interwiki && ':') + this.prefix;
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.ns = 0;
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.ns = ns;
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.fragment = fragment;
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.fragment !== undefined)
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.fragment === undefined
106
+ toString(display) {
107
+ return `${display ? this.title.replace(/_/gu, ' ') : this.title}${this.#fragment === undefined
102
108
  ? ''
103
- : `#${this.fragment}`}`;
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;
@@ -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
- '=': '\n',
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 `^(\0\d+c\x7F)*={1,6}|`}\[\[|-\{(?!\{)`, openBraces = String.raw `|\{{2,}`, { parserFunction: [, , , subst] } = config, stack = [];
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+c\x7F)*)$/u
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 = 'c';
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}c\x7F`;
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 str = `\0${accum.length}${name ? 'e' : 'c'}\x7F`;
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 str;
75
+ return `\0${l}${ch}\x7F`;
73
76
  });
74
77
  };
75
78
  exports.parseCommentAndExt = parseCommentAndExt;
@@ -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+c\x7F)*$)`, 'u'), stack = [];
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;