wikiparser-node 0.4.0 → 0.6.2-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 (86) hide show
  1. package/bundle/bundle.min.js +34 -0
  2. package/package.json +12 -5
  3. package/.eslintrc.json +0 -714
  4. package/README.md +0 -39
  5. package/config/default.json +0 -769
  6. package/config/llwiki.json +0 -630
  7. package/config/moegirl.json +0 -727
  8. package/config/zhwiki.json +0 -1269
  9. package/errors/README +0 -1
  10. package/index.js +0 -245
  11. package/jsconfig.json +0 -7
  12. package/lib/element.js +0 -755
  13. package/lib/node.js +0 -585
  14. package/lib/ranges.js +0 -131
  15. package/lib/text.js +0 -146
  16. package/lib/title.js +0 -69
  17. package/mixin/attributeParent.js +0 -113
  18. package/mixin/fixedToken.js +0 -40
  19. package/mixin/hidden.js +0 -19
  20. package/mixin/sol.js +0 -59
  21. package/parser/brackets.js +0 -112
  22. package/parser/commentAndExt.js +0 -63
  23. package/parser/converter.js +0 -45
  24. package/parser/externalLinks.js +0 -31
  25. package/parser/hrAndDoubleUnderscore.js +0 -35
  26. package/parser/html.js +0 -42
  27. package/parser/links.js +0 -98
  28. package/parser/list.js +0 -59
  29. package/parser/magicLinks.js +0 -41
  30. package/parser/quotes.js +0 -64
  31. package/parser/selector.js +0 -175
  32. package/parser/table.js +0 -112
  33. package/printed/README +0 -1
  34. package/printed/example.json +0 -120
  35. package/src/arg.js +0 -169
  36. package/src/atom/hidden.js +0 -13
  37. package/src/atom/index.js +0 -41
  38. package/src/attribute.js +0 -422
  39. package/src/converter.js +0 -157
  40. package/src/converterFlags.js +0 -232
  41. package/src/converterRule.js +0 -253
  42. package/src/extLink.js +0 -167
  43. package/src/gallery.js +0 -91
  44. package/src/heading.js +0 -100
  45. package/src/html.js +0 -202
  46. package/src/imageParameter.js +0 -254
  47. package/src/index.js +0 -737
  48. package/src/link/category.js +0 -53
  49. package/src/link/file.js +0 -265
  50. package/src/link/galleryImage.js +0 -61
  51. package/src/link/index.js +0 -322
  52. package/src/magicLink.js +0 -108
  53. package/src/nowiki/comment.js +0 -57
  54. package/src/nowiki/dd.js +0 -59
  55. package/src/nowiki/doubleUnderscore.js +0 -51
  56. package/src/nowiki/hr.js +0 -41
  57. package/src/nowiki/index.js +0 -44
  58. package/src/nowiki/list.js +0 -16
  59. package/src/nowiki/noinclude.js +0 -28
  60. package/src/nowiki/quote.js +0 -36
  61. package/src/onlyinclude.js +0 -54
  62. package/src/parameter.js +0 -187
  63. package/src/syntax.js +0 -83
  64. package/src/table/index.js +0 -967
  65. package/src/table/td.js +0 -308
  66. package/src/table/tr.js +0 -282
  67. package/src/tagPair/ext.js +0 -105
  68. package/src/tagPair/include.js +0 -50
  69. package/src/tagPair/index.js +0 -117
  70. package/src/transclude.js +0 -703
  71. package/test/api.js +0 -83
  72. package/test/real.js +0 -133
  73. package/test/test.js +0 -28
  74. package/test/util.js +0 -80
  75. package/tool/index.js +0 -918
  76. package/typings/api.d.ts +0 -13
  77. package/typings/array.d.ts +0 -28
  78. package/typings/event.d.ts +0 -24
  79. package/typings/index.d.ts +0 -94
  80. package/typings/node.d.ts +0 -29
  81. package/typings/parser.d.ts +0 -16
  82. package/typings/table.d.ts +0 -14
  83. package/typings/token.d.ts +0 -22
  84. package/typings/tool.d.ts +0 -11
  85. package/util/debug.js +0 -73
  86. package/util/string.js +0 -88
@@ -1,50 +0,0 @@
1
- 'use strict';
2
-
3
- const hidden = require('../../mixin/hidden'),
4
- Parser = require('../..'),
5
- TagPairToken = require('.');
6
-
7
- /**
8
- * `<includeonly>`或`<noinclude>`
9
- * @classdesc `{childNodes: [AstText, AstText]}`
10
- */
11
- class IncludeToken extends hidden(TagPairToken) {
12
- type = 'include';
13
-
14
- /**
15
- * @param {string} name 标签名
16
- * @param {string} attr 标签属性
17
- * @param {string|undefined} inner 内部wikitext
18
- * @param {string|undefined} closed 是否封闭
19
- * @param {accum} accum
20
- */
21
- constructor(name, attr = '', inner = undefined, closed = undefined, config = Parser.getConfig(), accum = []) {
22
- super(name, attr, inner ?? '', inner === undefined ? closed : closed ?? '', config, accum, {AstText: [0, 1]});
23
- }
24
-
25
- /** @override */
26
- cloneNode() {
27
- const tags = this.getAttribute('tags'),
28
- config = this.getAttribute('config'),
29
- inner = this.selfClosing ? undefined : String(this.lastChild),
30
- closing = this.selfClosing || !this.closed ? undefined : tags[1],
31
- token = Parser.run(() => new IncludeToken(tags[0], String(this.firstChild), inner, closing, config));
32
- return token;
33
- }
34
-
35
- /**
36
- * @override
37
- * @param {string} str 新文本
38
- */
39
- setText(str) {
40
- return super.setText(str, 1);
41
- }
42
-
43
- /** 清除标签属性 */
44
- removeAttr() {
45
- super.setText('', 0);
46
- }
47
- }
48
-
49
- Parser.classes.IncludeToken = __filename;
50
- module.exports = IncludeToken;
@@ -1,117 +0,0 @@
1
- 'use strict';
2
-
3
- const fixedToken = require('../../mixin/fixedToken'),
4
- Parser = require('../..'),
5
- Token = require('..');
6
-
7
- /**
8
- * 成对标签
9
- * @classdesc `{childNodes: [AstText|AttributeToken, AstText|Token]}`
10
- */
11
- class TagPairToken extends fixedToken(Token) {
12
- #selfClosing;
13
- #closed;
14
- #tags;
15
-
16
- /** getter */
17
- get selfClosing() {
18
- return this.#selfClosing;
19
- }
20
-
21
- set selfClosing(value) {
22
- value = Boolean(value);
23
- if (value !== this.#selfClosing && this.lastChild.text()) {
24
- Parser.warn(`<${this.name}>标签内部的${value ? '文本将被隐藏' : '原有文本将再次可见'}!`);
25
- }
26
- this.#selfClosing = value;
27
- }
28
-
29
- /** getter */
30
- get closed() {
31
- return this.#closed;
32
- }
33
-
34
- set closed(value) {
35
- this.#closed ||= Boolean(value);
36
- }
37
-
38
- /** 内部wikitext */
39
- get innerText() {
40
- return this.#selfClosing ? undefined : this.lastChild.text();
41
- }
42
-
43
- /**
44
- * @param {string} name 标签名
45
- * @param {string|Token} attr 标签属性
46
- * @param {string|Token} inner 内部wikitext
47
- * @param {string|undefined} closed 是否封闭;约定`undefined`表示自闭合,`''`表示未闭合
48
- * @param {accum} accum
49
- */
50
- constructor(name, attr, inner, closed, config = Parser.getConfig(), accum = []) {
51
- super(undefined, config, true);
52
- this.setAttribute('name', name.toLowerCase()).#tags = [name, closed || name];
53
- this.#selfClosing = closed === undefined;
54
- this.#closed = closed !== '';
55
- this.append(attr, inner);
56
- let index = accum.indexOf(attr);
57
- if (index === -1) {
58
- index = accum.indexOf(inner);
59
- }
60
- if (index === -1) {
61
- index = Infinity;
62
- }
63
- accum.splice(index, 0, this);
64
- }
65
-
66
- /**
67
- * @override
68
- * @template {string} T
69
- * @param {T} key 属性键
70
- * @returns {TokenAttribute<T>}
71
- */
72
- getAttribute(key) {
73
- return key === 'tags' ? [...this.#tags] : super.getAttribute(key);
74
- }
75
-
76
- /**
77
- * @override
78
- * @param {string} selector
79
- */
80
- toString(selector) {
81
- const {firstChild, lastChild, nextSibling, name} = this,
82
- [opening, closing] = this.#tags;
83
- if (selector && this.matches(selector)) {
84
- return '';
85
- } else if (!this.#closed && nextSibling) {
86
- Parser.error(`自动闭合 <${name}>`, lastChild);
87
- this.#closed = true;
88
- }
89
- return this.#selfClosing
90
- ? `<${opening}${String(firstChild)}/>`
91
- : `<${opening}${String(firstChild)}>${String(lastChild)}${this.#closed ? `</${closing}>` : ''}`;
92
- }
93
-
94
- /** @override */
95
- getPadding() {
96
- return this.#tags[0].length + 1;
97
- }
98
-
99
- /** @override */
100
- getGaps() {
101
- return 1;
102
- }
103
-
104
- /**
105
- * @override
106
- * @returns {string}
107
- */
108
- text() {
109
- const [opening, closing] = this.#tags;
110
- return this.#selfClosing
111
- ? `<${opening}${this.firstChild.text()}/>`
112
- : `<${opening}${super.text('>')}${this.#closed ? `</${closing}>` : ''}`;
113
- }
114
- }
115
-
116
- Parser.classes.TagPairToken = __filename;
117
- module.exports = TagPairToken;