wikiparser-node 0.9.0-m → 0.9.1-b

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 (77) hide show
  1. package/bundle/bundle.min.js +38 -0
  2. package/extensions/editor.css +62 -0
  3. package/extensions/editor.js +328 -0
  4. package/extensions/ui.css +119 -0
  5. package/package.json +12 -10
  6. package/config/default.json +0 -831
  7. package/config/llwiki.json +0 -595
  8. package/config/moegirl.json +0 -685
  9. package/config/zhwiki.json +0 -803
  10. package/index.js +0 -81
  11. package/lib/element.js +0 -136
  12. package/lib/node.js +0 -236
  13. package/lib/text.js +0 -150
  14. package/lib/title.js +0 -56
  15. package/mixin/hidden.js +0 -18
  16. package/parser/brackets.js +0 -125
  17. package/parser/commentAndExt.js +0 -58
  18. package/parser/converter.js +0 -45
  19. package/parser/externalLinks.js +0 -32
  20. package/parser/hrAndDoubleUnderscore.js +0 -37
  21. package/parser/html.js +0 -41
  22. package/parser/links.js +0 -93
  23. package/parser/list.js +0 -58
  24. package/parser/magicLinks.js +0 -40
  25. package/parser/quotes.js +0 -63
  26. package/parser/table.js +0 -113
  27. package/src/arg.js +0 -93
  28. package/src/atom/hidden.js +0 -11
  29. package/src/atom/index.js +0 -26
  30. package/src/attribute.js +0 -290
  31. package/src/attributes.js +0 -150
  32. package/src/converter.js +0 -70
  33. package/src/converterFlags.js +0 -97
  34. package/src/converterRule.js +0 -74
  35. package/src/extLink.js +0 -60
  36. package/src/gallery.js +0 -95
  37. package/src/hasNowiki/index.js +0 -32
  38. package/src/hasNowiki/pre.js +0 -28
  39. package/src/heading.js +0 -83
  40. package/src/html.js +0 -139
  41. package/src/imageParameter.js +0 -139
  42. package/src/imagemap.js +0 -140
  43. package/src/imagemapLink.js +0 -29
  44. package/src/index.js +0 -410
  45. package/src/link/category.js +0 -13
  46. package/src/link/file.js +0 -132
  47. package/src/link/galleryImage.js +0 -62
  48. package/src/link/index.js +0 -115
  49. package/src/magicLink.js +0 -66
  50. package/src/nested/choose.js +0 -23
  51. package/src/nested/combobox.js +0 -22
  52. package/src/nested/index.js +0 -66
  53. package/src/nested/references.js +0 -22
  54. package/src/nowiki/comment.js +0 -47
  55. package/src/nowiki/dd.js +0 -13
  56. package/src/nowiki/doubleUnderscore.js +0 -26
  57. package/src/nowiki/hr.js +0 -22
  58. package/src/nowiki/index.js +0 -34
  59. package/src/nowiki/list.js +0 -13
  60. package/src/nowiki/noinclude.js +0 -14
  61. package/src/nowiki/quote.js +0 -55
  62. package/src/onlyinclude.js +0 -39
  63. package/src/paramTag/index.js +0 -66
  64. package/src/paramTag/inputbox.js +0 -32
  65. package/src/parameter.js +0 -97
  66. package/src/syntax.js +0 -23
  67. package/src/table/index.js +0 -46
  68. package/src/table/td.js +0 -118
  69. package/src/table/tr.js +0 -74
  70. package/src/tagPair/ext.js +0 -128
  71. package/src/tagPair/include.js +0 -26
  72. package/src/tagPair/index.js +0 -77
  73. package/src/transclude.js +0 -336
  74. package/util/base.js +0 -17
  75. package/util/diff.js +0 -76
  76. package/util/lint.js +0 -55
  77. package/util/string.js +0 -75
@@ -1,13 +0,0 @@
1
- 'use strict';
2
-
3
- const LinkToken = require('.');
4
-
5
- /**
6
- * 分类
7
- * @classdesc `{childNodes: [AtomToken, ?Token]}`
8
- */
9
- class CategoryToken extends LinkToken {
10
- type = 'category';
11
- }
12
-
13
- module.exports = CategoryToken;
package/src/link/file.js DELETED
@@ -1,132 +0,0 @@
1
- 'use strict';
2
-
3
- const {explode} = require('../../util/string'),
4
- {generateForChild} = require('../../util/lint'),
5
- Parser = require('../..'),
6
- LinkToken = require('.'),
7
- ImageParameterToken = require('../imageParameter');
8
-
9
- const frame = new Set(['manualthumb', 'frameless', 'framed', 'thumbnail']),
10
- horizAlign = new Set(['left', 'right', 'center', 'none']),
11
- vertAlign = new Set(['baseline', 'sub', 'super', 'top', 'text-top', 'middle', 'bottom', 'text-bottom']);
12
-
13
- /**
14
- * 图片
15
- * @classdesc `{childNodes: [AtomToken, ...ImageParameterToken]}`
16
- */
17
- class FileToken extends LinkToken {
18
- type = 'file';
19
-
20
- /**
21
- * @param {string} link 文件名
22
- * @param {string|undefined} text 图片参数
23
- * @param {accum} accum
24
- * @param {string} delimiter `|`
25
- * @complexity `n`
26
- */
27
- constructor(link, text, config = Parser.getConfig(), accum = [], delimiter = '|') {
28
- super(link, undefined, config, accum, delimiter);
29
- this.append(...explode('-{', '}-', '|', text).map(part => new ImageParameterToken(part, config, accum)));
30
- }
31
-
32
- /**
33
- * @override
34
- * @param {number} start 起始位置
35
- */
36
- lint(start = this.getAbsoluteIndex()) {
37
- const errors = super.lint(start),
38
- args = this.getAllArgs().filter(({childNodes}) => {
39
- const visibleNodes = childNodes.filter(node => node.text().trim());
40
- return visibleNodes.length !== 1 || visibleNodes[0].type !== 'arg';
41
- }),
42
- keys = [...new Set(args.map(({name}) => name))].filter(key => key !== 'invalid'),
43
- frameKeys = keys.filter(key => frame.has(key)),
44
- horizAlignKeys = keys.filter(key => horizAlign.has(key)),
45
- vertAlignKeys = keys.filter(key => vertAlign.has(key));
46
- if (args.length === keys.length
47
- && frameKeys.length < 2 && horizAlignKeys.length < 2 && vertAlignKeys.length < 2
48
- ) {
49
- return errors;
50
- }
51
- const rect = {start, ...this.getRootNode().posFromIndex(start)};
52
- for (const key of keys) {
53
- let relevantArgs = args.filter(({name}) => name === key);
54
- if (key === 'caption') {
55
- relevantArgs = [
56
- ...relevantArgs.slice(0, -1).filter(arg => arg.text()),
57
- relevantArgs.at(-1),
58
- ];
59
- }
60
- if (relevantArgs.length > 1) {
61
- errors.push(...relevantArgs.map(
62
- arg => generateForChild(arg, rect, Parser.msg('duplicated image $1 parameter', key)),
63
- ));
64
- }
65
- }
66
- if (frameKeys.size > 1) {
67
- errors.push(
68
- ...args.filter(({name}) => frame.has(name)).map(
69
- arg => generateForChild(arg, rect, 'conflicting image $1 parameter', 'frame'),
70
- ),
71
- );
72
- }
73
- if (horizAlignKeys.size > 1) {
74
- errors.push(
75
- ...args.filter(({name}) => horizAlign.has(name))
76
- .map(arg => generateForChild(arg, rect, 'conflicting image $1 parameter', 'horizontal-alignment')),
77
- );
78
- }
79
- if (vertAlignKeys.size > 1) {
80
- errors.push(
81
- ...args.filter(({name}) => vertAlign.has(name))
82
- .map(arg => generateForChild(arg, rect, 'conflicting image $1 parameter', 'vertical-alignment')),
83
- );
84
- }
85
- return errors;
86
- }
87
-
88
- /**
89
- * 获取所有图片参数节点
90
- * @returns {ImageParameterToken[]}
91
- */
92
- getAllArgs() {
93
- return this.childNodes.slice(1);
94
- }
95
-
96
- /**
97
- * 获取指定图片参数
98
- * @param {string} key 参数名
99
- * @complexity `n`
100
- */
101
- getArgs(key) {
102
- return this.getAllArgs().filter(({name}) => key === name);
103
- }
104
-
105
- /**
106
- * 获取特定类型的图片属性参数节点
107
- * @param {Set<string>} keys 接受的参数名
108
- * @param {type} type 类型名
109
- * @complexity `n`
110
- */
111
- #getTypedArgs(keys, type) {
112
- const args = this.getAllArgs().filter(({name}) => keys.has(name));
113
- return args;
114
- }
115
-
116
- /** 获取图片框架属性参数节点 */
117
- getFrameArgs() {
118
- return this.#getTypedArgs(frame, '框架');
119
- }
120
-
121
- /** 获取图片水平对齐参数节点 */
122
- getHorizAlignArgs() {
123
- return this.#getTypedArgs(horizAlign, '水平对齐');
124
- }
125
-
126
- /** 获取图片垂直对齐参数节点 */
127
- getVertAlignArgs() {
128
- return this.#getTypedArgs(vertAlign, '垂直对齐');
129
- }
130
- }
131
-
132
- module.exports = FileToken;
@@ -1,62 +0,0 @@
1
- 'use strict';
2
-
3
- const {generateForSelf} = require('../../util/lint'),
4
- Parser = require('../..'),
5
- Token = require('..'),
6
- FileToken = require('./file');
7
-
8
- /**
9
- * 图片
10
- * @classdesc `{childNodes: [AtomToken, ...ImageParameterToken]}`
11
- */
12
- class GalleryImageToken extends FileToken {
13
- type = 'gallery-image';
14
- #invalid = false;
15
-
16
- /**
17
- * @param {string} link 图片文件名
18
- * @param {string|undefined} text 图片参数
19
- * @param {accum} accum
20
- */
21
- constructor(link, text, config = Parser.getConfig(), accum = []) {
22
- let token;
23
- if (text !== undefined) {
24
- token = new Token(text, config, true, accum);
25
- token.type = 'temp';
26
- for (let n = 1; n < Parser.MAX_STAGE; n++) {
27
- token.getAttribute('parseOnce')();
28
- }
29
- accum.splice(accum.indexOf(token), 1);
30
- }
31
- super(link, token?.toString(), config, accum);
32
- this.setAttribute('bracket', false);
33
- }
34
-
35
- /**
36
- * @override
37
- */
38
- afterBuild() {
39
- const initImagemap = this.type === 'imagemap-image',
40
- titleObj = this.normalizeTitle(String(this.firstChild), initImagemap ? 0 : 6, true, !initImagemap);
41
- this.#invalid = titleObj.ns !== 6; // 只用于gallery-image的首次解析
42
- }
43
-
44
- /** @override */
45
- getPadding() {
46
- return 0;
47
- }
48
-
49
- /**
50
- * @override
51
- * @param {number} start 起始位置
52
- */
53
- lint(start = this.getAbsoluteIndex()) {
54
- const errors = super.lint(start);
55
- if (this.#invalid) {
56
- errors.push(generateForSelf(this, {start}, 'invalid gallery image'));
57
- }
58
- return errors;
59
- }
60
- }
61
-
62
- module.exports = GalleryImageToken;
package/src/link/index.js DELETED
@@ -1,115 +0,0 @@
1
- 'use strict';
2
-
3
- const {generateForChild} = require('../../util/lint'),
4
- Parser = require('../..'),
5
- AstText = require('../../lib/text'),
6
- Token = require('..'),
7
- AtomToken = require('../atom');
8
-
9
- /**
10
- * 内链
11
- * @classdesc `{childNodes: [AtomToken, ?Token]}`
12
- */
13
- class LinkToken extends Token {
14
- type = 'link';
15
- #bracket = true;
16
- #delimiter;
17
- #fragment;
18
- #encoded = false;
19
-
20
- /**
21
- * @param {string} link 链接标题
22
- * @param {string|undefined} linkText 链接显示文字
23
- * @param {accum} accum
24
- * @param {string} delimiter `|`
25
- */
26
- constructor(link, linkText, config = Parser.getConfig(), accum = [], delimiter = '|') {
27
- super(undefined, config, true, accum, {
28
- });
29
- this.insertAt(new AtomToken(link, 'link-target', config, accum, {
30
- }));
31
- if (linkText !== undefined) {
32
- const inner = new Token(linkText, config, true, accum, {
33
- });
34
- inner.type = 'link-text';
35
- this.insertAt(inner.setAttribute('stage', Parser.MAX_STAGE - 1));
36
- }
37
- this.#delimiter = delimiter;
38
- }
39
-
40
- /**
41
- * @override
42
- */
43
- afterBuild() {
44
- const titleObj = this.normalizeTitle(this.firstChild.text(), 0, false, true, true);
45
- this.#fragment = titleObj.fragment;
46
- this.#encoded = titleObj.encoded;
47
- if (this.#delimiter?.includes('\0')) {
48
- this.#delimiter = this.getAttribute('buildFromStr')(this.#delimiter, 'string');
49
- }
50
- }
51
-
52
- /**
53
- * @override
54
- * @template {string} T
55
- * @param {T} key 属性键
56
- * @param {TokenAttribute<T>} value 属性值
57
- */
58
- setAttribute(key, value) {
59
- if (key === 'bracket') {
60
- this.#bracket = Boolean(value);
61
- return this;
62
- }
63
- return super.setAttribute(key, value);
64
- }
65
-
66
- /**
67
- * @override
68
- */
69
- toString(selector) {
70
- const str = super.toString(selector, this.#delimiter);
71
- return this.#bracket ? `[[${str}]]` : str;
72
- }
73
-
74
- /** @override */
75
- text() {
76
- const str = super.text('|');
77
- return this.#bracket ? `[[${str}]]` : str;
78
- }
79
-
80
- /** @override */
81
- getPadding() {
82
- return 2;
83
- }
84
-
85
- /** @override */
86
- getGaps() {
87
- return this.#delimiter.length;
88
- }
89
-
90
- /**
91
- * @override
92
- * @param {number} start 起始位置
93
- */
94
- lint(start = this.getAbsoluteIndex()) {
95
- const errors = super.lint(start),
96
- {childNodes: [target, linkText], type: linkType} = this;
97
- let rect;
98
- if (this.#encoded) {
99
- rect = {start, ...this.getRootNode().posFromIndex(start)};
100
- errors.push(generateForChild(target, rect, 'unnecessary URL encoding in an internal link'));
101
- }
102
- if (linkType === 'link' && linkText?.childNodes?.some(
103
- /** @param {AstText} */ ({type, data}) => type === 'text' && data.includes('|'),
104
- )) {
105
- rect ||= {start, ...this.getRootNode().posFromIndex(start)};
106
- errors.push(generateForChild(linkText, rect, 'additional "|" in the link text', 'warning'));
107
- } else if (linkType !== 'link' && this.#fragment !== undefined) {
108
- rect ||= {start, ...this.getRootNode().posFromIndex(start)};
109
- errors.push(generateForChild(target, rect, 'useless fragment'));
110
- }
111
- return errors;
112
- }
113
- }
114
-
115
- module.exports = LinkToken;
package/src/magicLink.js DELETED
@@ -1,66 +0,0 @@
1
- 'use strict';
2
-
3
- const {generateForChild} = require('../util/lint'),
4
- Parser = require('..'),
5
- Token = require('.');
6
-
7
- /**
8
- * 自由外链
9
- * @classdesc `{childNodes: [...AstText|CommentToken|IncludeToken|NoincludeToken]}`
10
- */
11
- class MagicLinkToken extends Token {
12
- type = 'free-ext-link';
13
-
14
- /**
15
- * @override
16
- * @param {number} start 起始位置
17
- */
18
- lint(start = this.getAbsoluteIndex()) {
19
- const errors = super.lint(start),
20
- source = `[,;。:!?()]+${this.type === 'ext-link-url' ? '|\\|+' : ''}`;
21
- let /** @type {{top: number, left: number}} */ rect;
22
- for (const child of this.childNodes) {
23
- const str = String(child);
24
- if (child.type !== 'text' || !new RegExp(source, 'u').test(str)) {
25
- continue;
26
- }
27
- rect ||= {start, ...this.getRootNode().posFromIndex(start)};
28
- const refError = generateForChild(child, rect, '', 'warning');
29
- errors.push(...[...str.matchAll(new RegExp(source, 'gu'))].map(({index, 0: {0: char, length}}) => {
30
- const lines = str.slice(0, index).split('\n'),
31
- {length: top} = lines,
32
- {length: left} = lines.at(-1),
33
- startIndex = start + index,
34
- startLine = refError.startLine + top - 1,
35
- startCol = (top > 1 ? 0 : refError.startCol) + left;
36
- return {
37
- ...refError,
38
- message: Parser.msg('$1 in URL', char === '|' ? '"|"' : Parser.msg('full-width punctuation')),
39
- startIndex,
40
- endIndex: startIndex + length,
41
- startLine,
42
- endLine: startLine,
43
- startCol,
44
- endCol: startCol + length,
45
- excerpt: str.slice(Math.max(0, index - 25), index + 25),
46
- };
47
- }));
48
- }
49
- return errors;
50
- }
51
-
52
- /**
53
- * @param {string} url 网址
54
- * @param {boolean} doubleSlash 是否接受"//"作为协议
55
- * @param {accum} accum
56
- */
57
- constructor(url, doubleSlash, config = Parser.getConfig(), accum = []) {
58
- super(url, config, true, accum, {
59
- });
60
- if (doubleSlash) {
61
- this.type = 'ext-link-url';
62
- }
63
- }
64
- }
65
-
66
- module.exports = MagicLinkToken;
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- const Parser = require('../..'),
4
- NestedToken = require('.');
5
-
6
- /**
7
- * `<choose>`
8
- * @classdesc `{childNodes: [...ExtToken|NoincludeToken]}`
9
- */
10
- class ChooseToken extends NestedToken {
11
- name = 'choose';
12
-
13
- /**
14
- * @param {string|undefined} wikitext wikitext
15
- * @param {accum} accum
16
- */
17
- constructor(wikitext, config = Parser.getConfig(), accum = []) {
18
- const regex = /<(option|choicetemplate)(\s[^>]*)?>(.*?)<\/(\1)>/gsu;
19
- super(wikitext, regex, ['option', 'choicetemplate'], config, accum);
20
- }
21
- }
22
-
23
- module.exports = ChooseToken;
@@ -1,22 +0,0 @@
1
- 'use strict';
2
-
3
- const Parser = require('../..'),
4
- NestedToken = require('.');
5
-
6
- /**
7
- * `<combobox>`
8
- * @classdesc `{childNodes: [...ExtToken|NoincludeToken]}`
9
- */
10
- class ComboboxToken extends NestedToken {
11
- name = 'combobox';
12
-
13
- /**
14
- * @param {string|undefined} wikitext wikitext
15
- * @param {accum} accum
16
- */
17
- constructor(wikitext, config = Parser.getConfig(), accum = []) {
18
- super(wikitext, /<(combooption)(\s[^>]*)?>(.*?)<\/(combooption\s*)>/gisu, ['combooption'], config, accum);
19
- }
20
- }
21
-
22
- module.exports = ComboboxToken;
@@ -1,66 +0,0 @@
1
- 'use strict';
2
-
3
- const {generateForChild} = require('../../util/lint'),
4
- Parser = require('../..'),
5
- Token = require('..'),
6
- ExtToken = require('../tagPair/ext'),
7
- NoincludeToken = require('../nowiki/noinclude'),
8
- CommentToken = require('../nowiki/comment');
9
-
10
- /**
11
- * 嵌套式的扩展标签
12
- * @classdesc `{childNodes: [...ExtToken|NoincludeToken|CommentToken]}`
13
- */
14
- class NestedToken extends Token {
15
- type = 'ext-inner';
16
-
17
- /**
18
- * @param {string|undefined} wikitext wikitext
19
- * @param {RegExp} regex 内层正则
20
- * @param {string[]} tags 内层标签名
21
- * @param {accum} accum
22
- */
23
- constructor(wikitext, regex, tags, config = Parser.getConfig(), accum = []) {
24
- const text = wikitext?.replace(
25
- regex,
26
- /** @type {function(...string): string} */ (comment, name, attr, inner, closing) => {
27
- const str = `\0${accum.length + 1}${name ? 'e' : 'c'}\x7F`;
28
- if (name) {
29
- new ExtToken(name, attr, inner, closing, config, accum);
30
- } else {
31
- const closed = comment.endsWith('-->');
32
- new CommentToken(comment.slice(4, closed ? -3 : undefined), closed, config, accum);
33
- }
34
- return str;
35
- },
36
- )?.replace(/(?<=^|\0\d+[ce]\x7F)[^\0]+(?=$|\0\d+[ce]\x7F)/gu, substr => {
37
- new NoincludeToken(substr, config, accum);
38
- return `\0${accum.length}c\x7F`;
39
- });
40
- super(text, config, true, accum, {
41
- });
42
- }
43
-
44
- /**
45
- * @override
46
- * @param {number} start 起始位置
47
- */
48
- lint(start = this.getAbsoluteIndex()) {
49
- let rect;
50
- return [
51
- ...super.lint(start),
52
- ...this.childNodes.filter(child => {
53
- if (child.type === 'ext' || child.type === 'comment') {
54
- return false;
55
- }
56
- const str = String(child).trim();
57
- return str && !/^<!--.*-->$/u.test(str);
58
- }).map(child => {
59
- rect ||= {start, ...this.getRootNode().posFromIndex(start)};
60
- return generateForChild(child, rect, Parser.msg('invalid content in <$1>', this.name));
61
- }),
62
- ];
63
- }
64
- }
65
-
66
- module.exports = NestedToken;
@@ -1,22 +0,0 @@
1
- 'use strict';
2
-
3
- const Parser = require('../..'),
4
- NestedToken = require('.');
5
-
6
- /**
7
- * `<references>`
8
- * @classdesc `{childNodes: [...ExtToken|NoincludeToken|CommentToken]}`
9
- */
10
- class ReferencesToken extends NestedToken {
11
- name = 'references';
12
-
13
- /**
14
- * @param {string|undefined} wikitext wikitext
15
- * @param {accum} accum
16
- */
17
- constructor(wikitext, config = Parser.getConfig(), accum = []) {
18
- super(wikitext, /<!--.*?(?:-->|$)|<(ref)(\s[^>]*)?>(.*?)<\/(ref\s*)>/gisu, ['ref'], config, accum);
19
- }
20
- }
21
-
22
- module.exports = ReferencesToken;
@@ -1,47 +0,0 @@
1
- 'use strict';
2
-
3
- const hidden = require('../../mixin/hidden'),
4
- {generateForSelf} = require('../../util/lint'),
5
- Parser = require('../..'),
6
- NowikiToken = require('.');
7
-
8
- /**
9
- * HTML注释,不可见
10
- * @classdesc `{childNodes: [AstText]}`
11
- */
12
- class CommentToken extends hidden(NowikiToken) {
13
- type = 'comment';
14
- closed;
15
-
16
- /**
17
- * @param {string} wikitext wikitext
18
- * @param {boolean} closed 是否闭合
19
- * @param {accum} accum
20
- */
21
- constructor(wikitext, closed = true, config = Parser.getConfig(), accum = []) {
22
- super(wikitext, config, accum);
23
- this.closed = closed;
24
- }
25
-
26
- /** @override */
27
- getPadding() {
28
- return 4;
29
- }
30
-
31
- /**
32
- * @override
33
- * @param {number} start 起始位置
34
- */
35
- lint(start = this.getAbsoluteIndex()) {
36
- return this.closed ? [] : [generateForSelf(this, {start}, 'unclosed HTML comment')];
37
- }
38
-
39
- /**
40
- * @override
41
- */
42
- toString(selector) {
43
- return `<!--${String(this.firstChild)}${this.closed ? '-->' : ''}`;
44
- }
45
- }
46
-
47
- module.exports = CommentToken;
package/src/nowiki/dd.js DELETED
@@ -1,13 +0,0 @@
1
- 'use strict';
2
-
3
- const NowikiToken = require('.');
4
-
5
- /**
6
- * :
7
- * @classdesc `{childNodes: [AstText]}`
8
- */
9
- class DdToken extends NowikiToken {
10
- type = 'dd';
11
- }
12
-
13
- module.exports = DdToken;
@@ -1,26 +0,0 @@
1
- 'use strict';
2
-
3
- const hidden = require('../../mixin/hidden'),
4
- NowikiToken = require('.');
5
-
6
- /**
7
- * 状态开关
8
- * @classdesc `{childNodes: [AstText]}`
9
- */
10
- class DoubleUnderscoreToken extends hidden(NowikiToken) {
11
- type = 'double-underscore';
12
-
13
- /** @override */
14
- getPadding() {
15
- return 2;
16
- }
17
-
18
- /**
19
- * @override
20
- */
21
- toString(selector) {
22
- return `__${String(this.firstChild)}__`;
23
- }
24
- }
25
-
26
- module.exports = DoubleUnderscoreToken;
package/src/nowiki/hr.js DELETED
@@ -1,22 +0,0 @@
1
- 'use strict';
2
-
3
- const Parser = require('../..'),
4
- NowikiToken = require('.');
5
-
6
- /**
7
- * `<hr>`
8
- * @classdesc `{childNodes: [AstText]}`
9
- */
10
- class HrToken extends NowikiToken {
11
- type = 'hr';
12
-
13
- /**
14
- * @param {number} n 字符串长度
15
- * @param {accum} accum
16
- */
17
- constructor(n, config = Parser.getConfig(), accum = []) {
18
- super('-'.repeat(n), config, accum);
19
- }
20
- }
21
-
22
- module.exports = HrToken;
@@ -1,34 +0,0 @@
1
- 'use strict';
2
-
3
- const {generateForSelf} = require('../../util/lint'),
4
- Parser = require('../..'),
5
- Token = require('..');
6
-
7
- /**
8
- * 纯文字Token,不会被解析
9
- * @classdesc `{childNodes: [AstText]}`
10
- */
11
- class NowikiToken extends Token {
12
- type = 'ext-inner';
13
-
14
- /**
15
- * @param {string} wikitext wikitext
16
- * @param {accum} accum
17
- */
18
- constructor(wikitext, config = Parser.getConfig(), accum = []) {
19
- super(wikitext, config, true, accum);
20
- }
21
-
22
- /**
23
- * @override
24
- * @param {number} start 起始位置
25
- */
26
- lint(start = this.getAbsoluteIndex()) {
27
- const {type, name} = this;
28
- return type === 'ext-inner' && (name === 'templatestyles' || name === 'section') && String(this)
29
- ? [generateForSelf(this, {start}, Parser.msg('nothing should be in <$1>', name))]
30
- : super.lint(start);
31
- }
32
- }
33
-
34
- module.exports = NowikiToken;
@@ -1,13 +0,0 @@
1
- 'use strict';
2
-
3
- const DdToken = require('./dd');
4
-
5
- /**
6
- * ;:*#
7
- * @classdesc `{childNodes: [AstText]}`
8
- */
9
- class ListToken extends DdToken {
10
- type = 'list';
11
- }
12
-
13
- module.exports = ListToken;