wikiparser-node 0.2.2 → 0.2.3

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.
@@ -646,65 +646,28 @@
646
646
  "wikt",
647
647
  "wiktionary",
648
648
  "zhwiki",
649
- "acronym",
650
- "c2find",
649
+ "cc",
651
650
  "cm",
652
- "dictionary",
653
- "drumcorpswiki",
654
- "dwjwiki",
655
- "elibre",
656
- "emacswiki",
657
651
  "enmoe",
658
- "enwiki",
659
- "foldoc",
660
- "foxwiki",
661
- "freebsdman",
662
- "gentoo-wiki",
663
- "hammondwiki",
664
- "hrwiki",
652
+ "enwp",
653
+ "fandom",
654
+ "ghia",
655
+ "huiji",
665
656
  "jamoe",
666
- "kmwiki",
657
+ "jawp",
667
658
  "library",
668
- "linuxwiki",
669
- "lojban",
670
- "lqwiki",
671
- "mcwiki",
672
- "meatball",
673
- "memoryalpha",
674
659
  "meta",
675
- "metawiki",
676
- "mozillawiki",
677
- "oeis",
678
- "openwiki",
679
660
  "phab",
680
661
  "pmid",
681
- "pythoninfo",
682
- "rfc",
683
- "s23wiki",
684
- "seattlewireless",
685
- "senseislibrary",
686
662
  "shoutwiki",
687
- "sourceforge",
688
- "squeak",
689
- "theopedia",
690
- "tmbw",
691
- "tmnet",
692
663
  "translatewiki",
693
- "twiki",
694
- "uncyclopedia",
695
- "unreal",
696
- "usemod",
697
- "wiki",
698
- "wikif1",
699
- "wikihow",
700
664
  "zhmoe",
701
665
  "zhmoegirl",
702
666
  "zhtest",
667
+ "zhwp",
703
668
  "文库",
704
- "维基中文",
705
- "维基日文",
706
- "维基英文",
707
669
  "萌娘共享",
670
+ "萌娘文库",
708
671
  "萌百"
709
672
  ],
710
673
  "img": {
@@ -578,20 +578,14 @@
578
578
  ],
579
579
  "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:",
580
580
  "interwiki": [
581
- "arxiv",
582
581
  "commons",
583
- "doi",
584
- "imdb",
585
- "jawiki",
586
582
  "mediawikiwiki",
587
583
  "metawikimedia",
588
584
  "mw",
589
- "wikia",
590
585
  "wikibooks",
591
586
  "wikidata",
592
587
  "wikimedia",
593
588
  "wikinews",
594
- "wikiinfo",
595
589
  "wikipedia",
596
590
  "wikiquote",
597
591
  "wikisource",
@@ -600,66 +594,31 @@
600
594
  "wikivoyage",
601
595
  "wikt",
602
596
  "wiktionary",
603
- "zhwiki",
604
- "acronym",
605
- "c2find",
597
+ "cc",
606
598
  "cm",
607
- "dictionary",
608
- "drumcorpswiki",
609
- "dwjwiki",
610
- "elibre",
611
- "emacswiki",
599
+ "en",
612
600
  "enmoe",
613
- "enwiki",
614
- "foldoc",
615
- "foxwiki",
616
- "freebsdman",
617
- "gentoo-wiki",
618
- "hammondwiki",
619
- "hrwiki",
601
+ "enwp",
602
+ "fandom",
603
+ "ghia",
604
+ "huiji",
605
+ "ja",
620
606
  "jamoe",
621
- "kmwiki",
607
+ "jawp",
622
608
  "library",
623
- "linuxwiki",
624
- "lojban",
625
- "lqwiki",
626
- "mcwiki",
627
- "meatball",
628
- "memoryalpha",
629
609
  "meta",
630
- "metawiki",
631
- "mozillawiki",
632
- "oeis",
633
- "openwiki",
634
610
  "phab",
635
611
  "pmid",
636
- "pythoninfo",
637
- "rfc",
638
- "s23wiki",
639
- "seattlewireless",
640
- "senseislibrary",
641
612
  "shoutwiki",
642
- "sourceforge",
643
- "squeak",
644
- "theopedia",
645
- "tmbw",
646
- "tmnet",
647
613
  "translatewiki",
648
- "twiki",
649
- "uncyclopedia",
650
- "unreal",
651
- "usemod",
652
- "wiki",
653
- "wikif1",
654
- "wikihow",
614
+ "zh",
655
615
  "zhmoe",
656
616
  "zhmoegirl",
657
617
  "zhtest",
618
+ "zhwp",
658
619
  "文库",
659
- "维基中文",
660
- "维基日文",
661
- "维基英文",
662
620
  "萌娘共享",
621
+ "萌娘文库",
663
622
  "萌百"
664
623
  ],
665
624
  "img": {
@@ -0,0 +1 @@
1
+ <!---->:
@@ -0,0 +1,11 @@
1
+ Error: ListToken 不可删除元素!
2
+ at ListToken.removeAt (/Users/mengxiwu/Documents/CCM-RP/node/wikiparser-node/mixin/fixedToken.js:14:9)
3
+ at ListToken.replaceChildren (/Users/mengxiwu/Documents/CCM-RP/node/wikiparser-node/lib/element.js:232:9)
4
+ at ListToken.build (/Users/mengxiwu/Documents/CCM-RP/node/wikiparser-node/src/index.js:500:8)
5
+ at Token.build (/Users/mengxiwu/Documents/CCM-RP/node/wikiparser-node/src/index.js:504:11)
6
+ at Token.parse (/Users/mengxiwu/Documents/CCM-RP/node/wikiparser-node/src/index.js:533:19)
7
+ at /Users/mengxiwu/Documents/CCM-RP/node/wikiparser-node/index.js:135:11
8
+ at Object.run (/Users/mengxiwu/Documents/CCM-RP/node/wikiparser-node/index.js:33:19)
9
+ at Object.parse (/Users/mengxiwu/Documents/CCM-RP/node/wikiparser-node/index.js:125:8)
10
+ at REPL8:1:10
11
+ at Script.runInThisContext (node:vm:130:12)
@@ -0,0 +1,5 @@
1
+ {
2
+ "stage": 11,
3
+ "include": false,
4
+ "config": "./config/default"
5
+ }
@@ -0,0 +1 @@
1
+ <!---->:
@@ -0,0 +1,11 @@
1
+ Error: ListToken 不可删除元素!
2
+ at ListToken.removeAt (/Users/mengxiwu/Documents/CCM-RP/node/wikiparser-node/mixin/fixedToken.js:14:9)
3
+ at ListToken.replaceChildren (/Users/mengxiwu/Documents/CCM-RP/node/wikiparser-node/lib/element.js:232:9)
4
+ at ListToken.build (/Users/mengxiwu/Documents/CCM-RP/node/wikiparser-node/src/index.js:500:8)
5
+ at Token.build (/Users/mengxiwu/Documents/CCM-RP/node/wikiparser-node/src/index.js:504:11)
6
+ at Token.parse (/Users/mengxiwu/Documents/CCM-RP/node/wikiparser-node/src/index.js:533:19)
7
+ at /Users/mengxiwu/Documents/CCM-RP/node/wikiparser-node/index.js:135:11
8
+ at Object.run (/Users/mengxiwu/Documents/CCM-RP/node/wikiparser-node/index.js:33:19)
9
+ at Object.parse (/Users/mengxiwu/Documents/CCM-RP/node/wikiparser-node/index.js:125:8)
10
+ at REPL68:1:10
11
+ at Script.runInThisContext (node:vm:130:12)
@@ -0,0 +1,5 @@
1
+ {
2
+ "stage": 11,
3
+ "include": false,
4
+ "config": "./config/default"
5
+ }
package/lib/element.js CHANGED
@@ -673,18 +673,11 @@ class AstElement extends AstNode {
673
673
  }
674
674
 
675
675
  /**
676
- * 不作为特殊语法的文字
677
- * @returns {[number, string][]}
676
+ * @returns {boolean}
678
677
  * @complexity `n`
679
678
  */
680
- plain() {
681
- const index = this.getAbsoluteIndex();
682
- return this.childNodes.flatMap((node, i) => {
683
- if (node instanceof AstElement) {
684
- return node.plain();
685
- }
686
- return node ? [[index + this.getRelativeIndex(i), node]] : [];
687
- });
679
+ get eof() {
680
+ return this.type === 'root' || !this.nextSibling && this.parentElement.eof;
688
681
  }
689
682
 
690
683
  /**
@@ -743,6 +736,11 @@ class AstElement extends AstNode {
743
736
  }
744
737
  Parser.info(`${indent}</${type}>`);
745
738
  }
739
+
740
+ /** @param {number} n */
741
+ getLine(n) {
742
+ return this.toString().split('\n', n + 1).at(-1);
743
+ }
746
744
  }
747
745
 
748
746
  Parser.classes.AstElement = __filename;
package/mixin/hidden.js CHANGED
@@ -11,11 +11,6 @@ const hidden = constructor => class extends constructor {
11
11
  text() {
12
12
  return '';
13
13
  }
14
-
15
- /** @returns {[number, string][]} */
16
- plain() {
17
- return [];
18
- }
19
14
  };
20
15
 
21
16
  Parser.mixins.hidden = __filename;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikiparser-node",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "A Node.js parser for MediaWiki markup with AST",
5
5
  "keywords": [
6
6
  "mediawiki",
@@ -10,7 +10,7 @@ const parseHrAndDoubleUnderscore = (firstChild, config = Parser.getConfig(), acc
10
10
  const HrToken = require('../src/nowiki/hr'),
11
11
  DoubleUnderscoreToken = require('../src/nowiki/doubleUnderscore'),
12
12
  {doubleUnderscore} = config;
13
- return firstChild.replace(/^-{4,}/mg, m => {
13
+ return firstChild.replace(/(?<=^(?:\x00\d+c\x7f)*)-{4,}/mg, m => {
14
14
  new HrToken(m.length, config, accum);
15
15
  return `\x00${accum.length - 1}r\x7f`;
16
16
  }).replace(new RegExp(`__(${doubleUnderscore.flat().join('|')})__`, 'ig'), /** @param {string} p1 */(m, p1) => {
package/parser/list.js CHANGED
@@ -7,13 +7,13 @@ const /** @type {Parser} */ Parser = require('..');
7
7
  * @param {accum} accum
8
8
  */
9
9
  const parseList = (text, config = Parser.getConfig(), accum = []) => {
10
- const mt = text.match(/^(?:[;:*#]|\x00\d+c\x7f)*[;:*#]/);
10
+ const mt = text.match(/^((?:\x00\d+c\x7f)*)([;:*#]+)/);
11
11
  if (!mt) {
12
12
  return text;
13
13
  }
14
14
  const ListToken = require('../src/nowiki/list'),
15
- [prefix] = mt;
16
- text = `\x00${accum.length}d\x7f${text.slice(prefix.length)}`;
15
+ [total, comment, prefix] = mt;
16
+ text = `${comment}\x00${accum.length}d\x7f${text.slice(total.length)}`;
17
17
  new ListToken(prefix, config, accum);
18
18
  let dt = prefix.split(';').length - 1;
19
19
  if (!dt) {
package/parser/table.js CHANGED
@@ -36,6 +36,9 @@ const parseTable = ({firstChild, type}, config = Parser.getConfig(), accum = [])
36
36
  const line = outLine.slice(spaces.length),
37
37
  matchesStart = line.match(/^(:*)((?:\s|\x00\d+c\x7f)*)({\||{\x00\d+!\x7f|\x00\d+{\x7f)(.*)/);
38
38
  if (matchesStart) {
39
+ while (top && top.type !== 'td') {
40
+ top = stack.pop();
41
+ }
39
42
  const [, indent, moreSpaces, tableSyntax, attr] = matchesStart;
40
43
  if (indent) {
41
44
  new DdToken(indent, config, accum);
package/src/arg.js CHANGED
@@ -73,11 +73,6 @@ class ArgToken extends Token {
73
73
  return `{{{${text(this.children.slice(0, 2), '|')}}}}`;
74
74
  }
75
75
 
76
- /** @returns {[number, string][]} */
77
- plain() {
78
- return this.childNodes.length > 1 ? this.children[1].plain() : [];
79
- }
80
-
81
76
  /** @complexity `n` */
82
77
  removeRedundant() {
83
78
  Parser.run(() => {
package/src/attribute.js CHANGED
@@ -82,7 +82,7 @@ class AttributeToken extends Token {
82
82
  * @param {accum} accum
83
83
  */
84
84
  constructor(attr, type, name, config = Parser.getConfig(), accum = []) {
85
- super(attr, config, type !== 'ext-attr', accum, {[`Stage-${stages[type]}`]: ':'});
85
+ super(attr, config, true, accum, {[`Stage-${stages[type]}`]: ':'});
86
86
  this.type = type;
87
87
  this.setAttribute('name', name).#parseAttr();
88
88
  }
@@ -253,11 +253,6 @@ class AttributeToken extends Token {
253
253
  return this.type === 'table-attr' ? normalizeSpace(str) : str;
254
254
  }
255
255
 
256
- /** @returns {[number, string][]} */
257
- plain() {
258
- return [];
259
- }
260
-
261
256
  /**
262
257
  * @param {number} i
263
258
  * @complexity `n`
package/src/converter.js CHANGED
@@ -19,7 +19,7 @@ class ConverterToken extends Token {
19
19
  * @param {accum} accum
20
20
  */
21
21
  constructor(flags, rules, config = Parser.getConfig(), accum = []) {
22
- super(undefined, config, false, accum);
22
+ super(undefined, config, true, accum);
23
23
  this.append(new ConverterFlagsToken(flags, config, accum));
24
24
  if (rules.length) {
25
25
  const [firstRule] = rules,
@@ -65,11 +65,6 @@ class ConverterToken extends Token {
65
65
  return `-{${flags.text()}|${text(rules, ';')}}-`;
66
66
  }
67
67
 
68
- /** @returns {[number, string][]} */
69
- plain() {
70
- return this.children.slice(1).flatMap(child => child.plain());
71
- }
72
-
73
68
  /** @this {ConverterToken & {firstChild: ConverterFlagsToken}} */
74
69
  getAllFlags() {
75
70
  return this.firstChild.getAllFlags();
@@ -17,7 +17,7 @@ class ConverterFlagsToken extends Token {
17
17
  * @param {accum} accum
18
18
  */
19
19
  constructor(flags, config = Parser.getConfig(), accum = []) {
20
- super(undefined, config, false, accum, {AtomToken: ':'});
20
+ super(undefined, config, true, accum, {AtomToken: ':'});
21
21
  this.append(...flags.map(flag => new AtomToken(flag, 'converter-flag', config, accum)));
22
22
  }
23
23
 
@@ -86,11 +86,6 @@ class ConverterFlagsToken extends Token {
86
86
  return super.text(';');
87
87
  }
88
88
 
89
- /** @returns {[number, string][]} */
90
- plain() {
91
- return [];
92
- }
93
-
94
89
  /**
95
90
  * @param {string} flag
96
91
  * @returns {AtomToken[]}
@@ -120,15 +120,6 @@ class ConverterRuleToken extends Token {
120
120
  return super.text(':');
121
121
  }
122
122
 
123
- /** @returns {[number, string][]} */
124
- plain() {
125
- const {firstElementChild, lastElementChild, unidirectional} = this;
126
- if (unidirectional) {
127
- return [...firstElementChild.plain(), ...lastElementChild.plain()];
128
- }
129
- return lastElementChild.plain();
130
- }
131
-
132
123
  noConvert() {
133
124
  for (let i = this.childNodes.length - 2; i >= 0; i--) {
134
125
  super.removeAt(i);
package/src/extLink.js CHANGED
@@ -77,14 +77,6 @@ class ExtLinkToken extends Token {
77
77
  return `[${super.text(' ').replaceAll('\n', ' ')}]`;
78
78
  }
79
79
 
80
- /**
81
- * @returns {[number, string][]}
82
- * @complexity `n`
83
- */
84
- plain() {
85
- return this.childNodes.length === 1 ? [] : this.lastElementChild.plain();
86
- }
87
-
88
80
  /** @this {ExtLinkToken & {firstElementChild: MagicLinkToken}} */
89
81
  getUrl() {
90
82
  return this.firstElementChild.getUrl();
package/src/gallery.js ADDED
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ const /** @type {Parser} */ Parser = require('..'),
4
+ Token = require('.'),
5
+ FileToken = require('./link/file');
6
+
7
+ /**
8
+ * 扩展标签
9
+ * @classdesc `{childNodes: [...FileToken]}`
10
+ */
11
+ class GalleryToken extends Token {
12
+ type = 'ext-inner';
13
+ name = 'gallery';
14
+
15
+ /** @param {accum} accum */
16
+ constructor(wikitext = '', config = Parser.getConfig(), accum = []) {
17
+ super(undefined, config, true, accum, {FileToken: ':'});
18
+ for (const line of wikitext.split('\n')) {
19
+ const [link, ...text] = line.split('|'),
20
+ title = Parser.normalizeTitle(link, 6, false, config);
21
+ this.appendChild(new FileToken(link, text.length ? text.join('|') : undefined, title, config, accum));
22
+ }
23
+ }
24
+
25
+ toString() {
26
+ return super.toString('\n');
27
+ }
28
+ }
29
+
30
+ Parser.classes.GalleryToken = __filename;
31
+ module.exports = GalleryToken;
package/src/heading.js CHANGED
@@ -63,11 +63,6 @@ class HeadingToken extends fixedToken(sol(Token)) {
63
63
  return `${this.prependNewLine()}${equals}${this.firstElementChild.text()}${equals}${this.appendNewLine()}`;
64
64
  }
65
65
 
66
- /** @returns {[number, string][]} */
67
- plain() {
68
- return this.firstElementChild.plain();
69
- }
70
-
71
66
  /** @param {number} n */
72
67
  setLevel(n) {
73
68
  if (typeof n !== 'number') {
package/src/html.js CHANGED
@@ -62,11 +62,6 @@ class HtmlToken extends attributeParent(fixedToken(Token)) {
62
62
  return `<${this.closing ? '/' : ''}${this.#tag}${super.text()}${this.selfClosing ? '/' : ''}>`;
63
63
  }
64
64
 
65
- /** @returns {[number, string][]} */
66
- plain() {
67
- return [];
68
- }
69
-
70
65
  /** @param {string} tag */
71
66
  replaceTag(tag) {
72
67
  const name = tag.toLowerCase();
@@ -12,6 +12,7 @@ class CategoryToken extends LinkToken {
12
12
  type = 'category';
13
13
  sortkey = '';
14
14
 
15
+ setLangLink = undefined;
15
16
  setFragment = undefined;
16
17
  asSelfLink = undefined;
17
18
  pipeTrick = undefined;
@@ -74,11 +75,6 @@ class CategoryToken extends LinkToken {
74
75
  return `[[${this.firstElementChild.text()}]]`;
75
76
  }
76
77
 
77
- /** @returns {[number, string][]} */
78
- plain() {
79
- return [];
80
- }
81
-
82
78
  /** @param {string} text */
83
79
  setSortkey(text) {
84
80
  this.setLinkText(text);
package/src/link/file.js CHANGED
@@ -15,6 +15,7 @@ class FileToken extends LinkToken {
15
15
  /** @type {Set<string>} */ #keys = new Set();
16
16
  /** @type {Record<string, Set<ImageParameterToken>>} */ #args = {};
17
17
 
18
+ setLangLink = undefined;
18
19
  setFragment = undefined;
19
20
  asSelfLink = undefined;
20
21
  setLinkText = undefined;
package/src/link/index.js CHANGED
@@ -90,7 +90,8 @@ class LinkToken extends Token {
90
90
  }
91
91
 
92
92
  toString() {
93
- return `[[${super.toString('|')}]]`;
93
+ const str = super.toString('|');
94
+ return this.parentElement?.matches('ext-inner#gallery') ? str : `[[${str}]]`;
94
95
  }
95
96
 
96
97
  getPadding() {
@@ -105,11 +106,6 @@ class LinkToken extends Token {
105
106
  return `[[${super.text('|')}]]`;
106
107
  }
107
108
 
108
- /** @returns {[number, string][]} */
109
- plain() {
110
- return this.childNodes.length === 1 ? [] : this.lastElementChild.plain();
111
- }
112
-
113
109
  /** @param {string} link */
114
110
  setTarget(link) {
115
111
  link = String(link);
@@ -128,6 +124,33 @@ class LinkToken extends Token {
128
124
  this.firstElementChild.safeReplaceWith(firstChild);
129
125
  }
130
126
 
127
+ /**
128
+ * @param {string} lang
129
+ * @param {string} link
130
+ */
131
+ setLangLink(lang, link) {
132
+ if (typeof lang !== 'string') {
133
+ this.typeError('setLangLink', 'String');
134
+ }
135
+ link = String(link).trim();
136
+ if (link.startsWith('#')) {
137
+ throw new SyntaxError(`跨语言链接不能仅为fragment!`);
138
+ } else if (link.startsWith(':')) {
139
+ link = link.slice(1);
140
+ }
141
+ const root = Parser.parse(`[[${lang}:${link}]]`, this.getAttribute('include'), 6, this.getAttribute('config')),
142
+ /** @type {Token & {firstElementChild: LinkToken}} */ {childNodes: {length}, firstElementChild} = root;
143
+ if (length !== 1 || firstElementChild?.type !== 'link' || firstElementChild.childNodes.length !== 1
144
+ || firstElementChild.interwiki !== lang.toLowerCase()
145
+ ) {
146
+ throw new SyntaxError(`非法的跨语言链接目标:${lang}:${link}`);
147
+ }
148
+ const {firstChild} = firstElementChild;
149
+ root.destroy();
150
+ firstElementChild.destroy();
151
+ this.firstElementChild.safeReplaceWith(firstChild);
152
+ }
153
+
131
154
  /** @param {string} fragment */
132
155
  #setFragment(fragment, page = true) {
133
156
  fragment = String(fragment).replace(/[<>[]#|=!]/g, p => encodeURIComponent(p));
package/src/nowiki/dd.js CHANGED
@@ -29,11 +29,6 @@ class DdToken extends NowikiToken {
29
29
  this.seal(['dt', 'ul', 'ol', 'indent']).#update(str);
30
30
  }
31
31
 
32
- /** @returns {[number, string][]} */
33
- plain() {
34
- return [];
35
- }
36
-
37
32
  /** @param {string} str */
38
33
  setText(str) {
39
34
  const src = this.type === 'dd' ? ':' : ';:*#';
package/src/nowiki/hr.js CHANGED
@@ -24,11 +24,6 @@ class HrToken extends sol(NowikiToken) {
24
24
  return Parser.run(() => new HrToken(this.firstChild.length, this.getAttribute('config')));
25
25
  }
26
26
 
27
- /** @returns {[number, string][]} */
28
- plain() {
29
- return [];
30
- }
31
-
32
27
  /** @param {string} str */
33
28
  setText(str) {
34
29
  if (!/^-{4,}$/.test(str)) {
@@ -16,7 +16,7 @@ class NowikiToken extends fixedToken(Token) {
16
16
  * @param {accum} accum
17
17
  */
18
18
  constructor(wikitext, config = Parser.getConfig(), accum = []) {
19
- super(wikitext, config, false, accum);
19
+ super(wikitext, config, true, accum);
20
20
  }
21
21
 
22
22
  /** @this {NowikiToken & {firstChild: string}} */
@@ -26,11 +26,6 @@ class QuoteToken extends NowikiToken {
26
26
  }
27
27
  return super.setText(str);
28
28
  }
29
-
30
- /** @returns {[number, string][]} */
31
- plain() {
32
- return [];
33
- }
34
29
  }
35
30
 
36
31
  Parser.classes.QuoteToken = __filename;
@@ -15,7 +15,7 @@ class OnlyincludeToken extends Token {
15
15
  * @param {accum} accum
16
16
  */
17
17
  constructor(inner, config = Parser.getConfig(), accum = []) {
18
- super(inner, config, false, accum);
18
+ super(inner, config, true, accum);
19
19
  }
20
20
 
21
21
  cloneNode() {
package/src/parameter.js CHANGED
@@ -85,11 +85,6 @@ class ParameterToken extends fixedToken(Token) {
85
85
  return this.anon ? this.lastElementChild.text() : super.text('=');
86
86
  }
87
87
 
88
- /** @returns {[number, string][]} */
89
- plain() {
90
- return this.lastElementChild.plain();
91
- }
92
-
93
88
  /**
94
89
  * @param {ParameterToken} token
95
90
  * @complexity `n`
package/src/syntax.js CHANGED
@@ -60,11 +60,6 @@ class SyntaxToken extends Token {
60
60
  return super.getAttribute(key);
61
61
  }
62
62
 
63
- /** @returns {[number, string][]} */
64
- plain() {
65
- return [];
66
- }
67
-
68
63
  /**
69
64
  * @param {...string|Token} elements
70
65
  * @complexity `n`
@@ -79,6 +79,10 @@ class ExtToken extends attributeParent(TagPairToken) {
79
79
  token.lastElementChild.safeReplaceWith(inner);
80
80
  return token;
81
81
  }
82
+
83
+ get innerText() {
84
+ return this.selfClosing ? '' : this.lastElementChild.text();
85
+ }
82
86
  }
83
87
 
84
88
  Parser.classes.ExtToken = __filename;
@@ -21,7 +21,7 @@ class TagPairToken extends fixedToken(Token) {
21
21
  * @param {accum} accum
22
22
  */
23
23
  constructor(name, attr, inner, closing, config = Parser.getConfig(), accum = []) {
24
- super(undefined, config);
24
+ super(undefined, config, true);
25
25
  this.setAttribute('name', name.toLowerCase()).#tags = [name, closing || name];
26
26
  this.selfClosing = closing === undefined;
27
27
  this.closed = closing !== '';
@@ -76,15 +76,6 @@ class TagPairToken extends fixedToken(Token) {
76
76
  ? `<${opening}${typeof firstChild === 'string' ? firstChild : firstChild.text()}/>`
77
77
  : `<${opening}${super.text('>')}${closed ? `</${closing}>` : ''}`;
78
78
  }
79
-
80
- /** @returns {[number, string][]} */
81
- plain() {
82
- const {lastChild} = this;
83
- if (typeof lastChild === 'string') {
84
- return lastChild ? [[this.getAbsoluteIndex() + this.getRelativeIndex(1), lastChild]] : [];
85
- }
86
- return lastChild.plain();
87
- }
88
79
  }
89
80
 
90
81
  Parser.classes.TagPairToken = __filename;
package/src/transclude.js CHANGED
@@ -209,10 +209,6 @@ class TranscludeToken extends Token {
209
209
  }}}`;
210
210
  }
211
211
 
212
- plain() {
213
- return this.getAllArgs().flatMap(child => child.plain());
214
- }
215
-
216
212
  /**
217
213
  * @param {number|ParameterToken} addedToken
218
214
  * @complexity `n`