wikiparser-node 1.0.0-beta.4 → 1.0.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 (145) hide show
  1. package/README.md +10 -9
  2. package/bundle/bundle.min.js +37 -0
  3. package/config/llwiki.json +1 -35
  4. package/config/moegirl.json +1 -44
  5. package/config/zhwiki.json +1 -466
  6. package/extensions/dist/base.js +105 -0
  7. package/extensions/dist/editor.js +172 -0
  8. package/extensions/dist/highlight.js +46 -0
  9. package/extensions/dist/lint.js +43 -0
  10. package/extensions/editor.css +63 -0
  11. package/extensions/ui.css +119 -0
  12. package/package.json +29 -16
  13. package/config/.schema.json +0 -160
  14. package/dist/index.d.ts +0 -62
  15. package/dist/index.js +0 -305
  16. package/dist/internal.d.ts +0 -44
  17. package/dist/lib/element.d.ts +0 -190
  18. package/dist/lib/element.js +0 -674
  19. package/dist/lib/node.d.ts +0 -178
  20. package/dist/lib/node.js +0 -457
  21. package/dist/lib/range.d.ts +0 -132
  22. package/dist/lib/range.js +0 -384
  23. package/dist/lib/ranges.d.ts +0 -28
  24. package/dist/lib/ranges.js +0 -125
  25. package/dist/lib/text.d.ts +0 -78
  26. package/dist/lib/text.js +0 -227
  27. package/dist/lib/title.d.ts +0 -34
  28. package/dist/lib/title.js +0 -111
  29. package/dist/mixin/attributesParent.js +0 -93
  30. package/dist/mixin/fixed.js +0 -32
  31. package/dist/mixin/hidden.js +0 -23
  32. package/dist/mixin/singleLine.js +0 -26
  33. package/dist/mixin/sol.js +0 -44
  34. package/dist/parser/braces.js +0 -120
  35. package/dist/parser/commentAndExt.js +0 -64
  36. package/dist/parser/converter.js +0 -39
  37. package/dist/parser/externalLinks.js +0 -27
  38. package/dist/parser/hrAndDoubleUnderscore.js +0 -37
  39. package/dist/parser/html.js +0 -35
  40. package/dist/parser/links.js +0 -93
  41. package/dist/parser/list.js +0 -58
  42. package/dist/parser/magicLinks.js +0 -39
  43. package/dist/parser/quotes.js +0 -66
  44. package/dist/parser/selector.js +0 -162
  45. package/dist/parser/table.js +0 -108
  46. package/dist/src/arg.d.ts +0 -78
  47. package/dist/src/arg.js +0 -203
  48. package/dist/src/atom.d.ts +0 -12
  49. package/dist/src/atom.js +0 -24
  50. package/dist/src/attribute.d.ts +0 -107
  51. package/dist/src/attribute.js +0 -446
  52. package/dist/src/attributes.d.ts +0 -120
  53. package/dist/src/attributes.js +0 -360
  54. package/dist/src/converter.d.ts +0 -76
  55. package/dist/src/converter.js +0 -134
  56. package/dist/src/converterFlags.d.ts +0 -108
  57. package/dist/src/converterFlags.js +0 -237
  58. package/dist/src/converterRule.d.ts +0 -97
  59. package/dist/src/converterRule.js +0 -253
  60. package/dist/src/extLink.d.ts +0 -64
  61. package/dist/src/extLink.js +0 -156
  62. package/dist/src/gallery.d.ts +0 -72
  63. package/dist/src/gallery.js +0 -133
  64. package/dist/src/heading.d.ts +0 -84
  65. package/dist/src/heading.js +0 -134
  66. package/dist/src/hidden.d.ts +0 -20
  67. package/dist/src/hidden.js +0 -26
  68. package/dist/src/html.d.ts +0 -115
  69. package/dist/src/html.js +0 -247
  70. package/dist/src/imageParameter.d.ts +0 -83
  71. package/dist/src/imageParameter.js +0 -255
  72. package/dist/src/imagemap.d.ts +0 -79
  73. package/dist/src/imagemap.js +0 -164
  74. package/dist/src/imagemapLink.d.ts +0 -49
  75. package/dist/src/imagemapLink.js +0 -39
  76. package/dist/src/index.d.ts +0 -157
  77. package/dist/src/index.js +0 -818
  78. package/dist/src/link/base.d.ts +0 -70
  79. package/dist/src/link/base.js +0 -229
  80. package/dist/src/link/category.d.ts +0 -14
  81. package/dist/src/link/category.js +0 -29
  82. package/dist/src/link/file.d.ts +0 -106
  83. package/dist/src/link/file.js +0 -271
  84. package/dist/src/link/galleryImage.d.ts +0 -37
  85. package/dist/src/link/galleryImage.js +0 -101
  86. package/dist/src/link/index.d.ts +0 -50
  87. package/dist/src/link/index.js +0 -136
  88. package/dist/src/magicLink.d.ts +0 -47
  89. package/dist/src/magicLink.js +0 -130
  90. package/dist/src/nested.d.ts +0 -49
  91. package/dist/src/nested.js +0 -88
  92. package/dist/src/nowiki/base.d.ts +0 -39
  93. package/dist/src/nowiki/base.js +0 -31
  94. package/dist/src/nowiki/comment.d.ts +0 -43
  95. package/dist/src/nowiki/comment.js +0 -62
  96. package/dist/src/nowiki/dd.d.ts +0 -22
  97. package/dist/src/nowiki/dd.js +0 -47
  98. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -37
  99. package/dist/src/nowiki/doubleUnderscore.js +0 -48
  100. package/dist/src/nowiki/hr.d.ts +0 -24
  101. package/dist/src/nowiki/hr.js +0 -29
  102. package/dist/src/nowiki/index.d.ts +0 -20
  103. package/dist/src/nowiki/index.js +0 -24
  104. package/dist/src/nowiki/list.d.ts +0 -16
  105. package/dist/src/nowiki/list.js +0 -14
  106. package/dist/src/nowiki/noinclude.d.ts +0 -21
  107. package/dist/src/nowiki/noinclude.js +0 -25
  108. package/dist/src/nowiki/quote.d.ts +0 -20
  109. package/dist/src/nowiki/quote.js +0 -66
  110. package/dist/src/onlyinclude.d.ts +0 -39
  111. package/dist/src/onlyinclude.js +0 -66
  112. package/dist/src/paramTag/index.d.ts +0 -52
  113. package/dist/src/paramTag/index.js +0 -78
  114. package/dist/src/paramTag/inputbox.d.ts +0 -8
  115. package/dist/src/paramTag/inputbox.js +0 -22
  116. package/dist/src/parameter.d.ts +0 -96
  117. package/dist/src/parameter.js +0 -203
  118. package/dist/src/pre.d.ts +0 -29
  119. package/dist/src/pre.js +0 -49
  120. package/dist/src/syntax.d.ts +0 -23
  121. package/dist/src/syntax.js +0 -67
  122. package/dist/src/table/base.d.ts +0 -61
  123. package/dist/src/table/base.js +0 -78
  124. package/dist/src/table/index.d.ts +0 -248
  125. package/dist/src/table/index.js +0 -782
  126. package/dist/src/table/td.d.ts +0 -121
  127. package/dist/src/table/td.js +0 -267
  128. package/dist/src/table/tr.d.ts +0 -32
  129. package/dist/src/table/tr.js +0 -51
  130. package/dist/src/table/trBase.d.ts +0 -62
  131. package/dist/src/table/trBase.js +0 -157
  132. package/dist/src/tagPair/ext.d.ts +0 -55
  133. package/dist/src/tagPair/ext.js +0 -138
  134. package/dist/src/tagPair/include.d.ts +0 -43
  135. package/dist/src/tagPair/include.js +0 -42
  136. package/dist/src/tagPair/index.d.ts +0 -57
  137. package/dist/src/tagPair/index.js +0 -107
  138. package/dist/src/transclude.d.ts +0 -201
  139. package/dist/src/transclude.js +0 -727
  140. package/dist/util/debug.js +0 -42
  141. package/dist/util/diff.js +0 -71
  142. package/dist/util/lint.js +0 -48
  143. package/dist/util/string.js +0 -75
  144. package/errors/README +0 -1
  145. package/printed/README +0 -1
@@ -0,0 +1,172 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ (() => {
11
+ const { wikiparse } = window, { MAX_STAGE } = wikiparse;
12
+ /** 用于打印AST */
13
+ class Printer {
14
+ /* eslint-enable es-x/no-class-fields */
15
+ /**
16
+ * @param preview 置于下层的代码高亮
17
+ * @param textbox 置于上层的文本框
18
+ * @param include 是否嵌入
19
+ */
20
+ constructor(preview, textbox, include) {
21
+ this.id = wikiparse.id++;
22
+ this.include = Boolean(include);
23
+ this.preview = preview;
24
+ this.textbox = textbox;
25
+ this.root = [];
26
+ this.running = undefined;
27
+ this.viewportChanged = false;
28
+ this.ticks = [0, undefined];
29
+ }
30
+ /** 倒计时 */
31
+ tick() {
32
+ setTimeout(() => {
33
+ const { ticks } = this;
34
+ if (ticks[0] > 0) {
35
+ ticks[0] -= 500;
36
+ this[ticks[0] <= 0 ? ticks[1] : 'tick']();
37
+ }
38
+ }, 500);
39
+ }
40
+ /**
41
+ * 用于debounce
42
+ * @param delay 延迟
43
+ * @param method 方法
44
+ */
45
+ queue(delay, method) {
46
+ const { ticks } = this, [state] = ticks;
47
+ if (state <= 0 || method === 'coarsePrint' || ticks[1] !== 'coarsePrint') {
48
+ ticks[0] = delay;
49
+ ticks[1] = method;
50
+ if (state <= 0) {
51
+ this.tick();
52
+ }
53
+ }
54
+ }
55
+ /** 渲染 */
56
+ paint() {
57
+ this.preview.innerHTML = `<span class="wpb-root">${this.root.map(([, , printed]) => printed).join('')}</span> `;
58
+ this.preview.scrollTop = this.textbox.scrollTop;
59
+ this.preview.classList.remove('active');
60
+ this.textbox.style.color = 'transparent';
61
+ }
62
+ /** 初步解析 */
63
+ coarsePrint() {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ if (this.running) {
66
+ return undefined;
67
+ }
68
+ const { include, textbox: { value } } = this, parsed = yield wikiparse.print(value, include, 2, this.id);
69
+ if (this.include !== include || this.textbox.value !== value) {
70
+ this.running = undefined;
71
+ this.running = this.coarsePrint();
72
+ return this.running;
73
+ }
74
+ this.root = parsed;
75
+ this.paint();
76
+ this.running = undefined;
77
+ this.running = this.finePrint();
78
+ return this.running;
79
+ });
80
+ }
81
+ /** 根据可见范围精细解析 */
82
+ finePrint() {
83
+ return __awaiter(this, void 0, void 0, function* () {
84
+ if (this.running) {
85
+ this.viewportChanged = true;
86
+ return undefined;
87
+ }
88
+ this.viewportChanged = false;
89
+ const { root, preview: { scrollHeight, offsetHeight: parentHeight, scrollTop, children: [rootNode] }, include, textbox: { value }, } = this;
90
+ let text = value, start = 0, { length: end } = root;
91
+ if (scrollHeight > parentHeight) {
92
+ const childNodes = [...rootNode.childNodes], headings = childNodes.filter(({ className }) => className === 'wpb-heading'), { length } = headings;
93
+ if (length > 0) {
94
+ let i = headings.findIndex(({ offsetTop, offsetHeight }) => offsetTop + offsetHeight > scrollTop);
95
+ i = i === -1 ? length : i;
96
+ let j = headings.slice(i).findIndex(({ offsetTop }) => offsetTop >= scrollTop + parentHeight);
97
+ j = j === -1 ? length : i + j;
98
+ start = i ? childNodes.indexOf(headings[i - 1]) : 0;
99
+ while (i <= j && root[start][0] === MAX_STAGE) {
100
+ start = childNodes.indexOf(headings[i++]);
101
+ }
102
+ end = j === length ? end : childNodes.indexOf(headings[j]);
103
+ while (i <= j && root[end - 1][0] === MAX_STAGE) {
104
+ end = childNodes.indexOf(headings[--j]);
105
+ }
106
+ text = root.slice(start, end).map(([, str]) => str).join('');
107
+ }
108
+ }
109
+ if (start === end) {
110
+ this.running = undefined;
111
+ return undefined;
112
+ }
113
+ const parsed = yield wikiparse.print(text, include, MAX_STAGE, this.id);
114
+ if (this.include === include && this.textbox.value === value) {
115
+ this.root.splice(start, end - start, ...parsed);
116
+ this.paint();
117
+ this.running = undefined;
118
+ if (this.viewportChanged) {
119
+ this.running = this.finePrint();
120
+ }
121
+ }
122
+ else {
123
+ this.running = undefined;
124
+ this.running = this.coarsePrint();
125
+ }
126
+ return this.running;
127
+ });
128
+ }
129
+ }
130
+ /**
131
+ * 高亮textarea
132
+ * @param textbox textarea元素
133
+ * @param include 是否嵌入
134
+ * @throws `TypeError` 不是textarea
135
+ */
136
+ const edit = (textbox, include) => {
137
+ if (!(textbox instanceof HTMLTextAreaElement)) {
138
+ throw new TypeError('wikiparse.edit方法仅可用于textarea元素!');
139
+ }
140
+ const preview = document.createElement('div'), container = document.createElement('div'), printer = new Printer(preview, textbox, include);
141
+ preview.id = 'wikiPretty';
142
+ preview.classList.add('wikiparser', 'active');
143
+ container.classList.add('wikiparse-container');
144
+ textbox.replaceWith(container);
145
+ textbox.classList.add('wikiparsed');
146
+ container.append(preview, textbox);
147
+ textbox.addEventListener('input', e => {
148
+ if (!e.isComposing) {
149
+ printer.queue(2000, 'coarsePrint');
150
+ }
151
+ textbox.style.color = '';
152
+ preview.classList.add('active');
153
+ });
154
+ textbox.addEventListener('scroll', () => {
155
+ if (preview.scrollHeight > preview.offsetHeight && !preview.classList.contains('active')) {
156
+ preview.scrollTop = textbox.scrollTop;
157
+ printer.queue(500, 'finePrint');
158
+ }
159
+ });
160
+ textbox.addEventListener('keydown', e => {
161
+ if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
162
+ e.preventDefault();
163
+ printer.ticks[0] = 0;
164
+ printer.running = printer.coarsePrint();
165
+ }
166
+ });
167
+ printer.running = printer.coarsePrint();
168
+ return printer;
169
+ };
170
+ wikiparse.Printer = Printer;
171
+ wikiparse.edit = edit;
172
+ })();
@@ -0,0 +1,46 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ (() => {
11
+ const { wikiparse } = window;
12
+ /**
13
+ * 高亮代码块
14
+ * @param ele 代码块
15
+ * @param linenums 是否添加行号
16
+ * @param start 起始行号
17
+ */
18
+ const highlight = (ele, linenums, start = 1) => __awaiter(void 0, void 0, void 0, function* () {
19
+ if (ele.classList.contains('highlighted')) {
20
+ return;
21
+ }
22
+ const html = (yield wikiparse.print(ele.innerText)).map(([, , printed]) => printed).join('');
23
+ ele.classList.add('highlighted');
24
+ if (linenums) {
25
+ // 添加行号。这里不使用<table>排版,而是使用<ol>
26
+ const lines = html.split('\n').map((line, i) => {
27
+ const li = document.createElement('li');
28
+ li.id = `L${i + start}`;
29
+ li.innerHTML = line;
30
+ return li;
31
+ });
32
+ if (!lines[lines.length - 1].textContent) {
33
+ lines.pop();
34
+ }
35
+ const ol = document.createElement('ol');
36
+ ol.start = start;
37
+ ol.style.paddingLeft = `${(lines.length + start - 1).toString().length + 2.5}ch`;
38
+ ol.append(...lines);
39
+ ele.replaceChildren(ol);
40
+ }
41
+ else {
42
+ ele.innerHTML = html;
43
+ }
44
+ });
45
+ wikiparse.highlight = highlight;
46
+ })();
@@ -0,0 +1,43 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ (() => {
11
+ const { wikiparse } = window;
12
+ /** 用于语法分析 */
13
+ class Linter {
14
+ /* eslint-enable es-x/no-class-fields */
15
+ /** @param include 是否嵌入 */
16
+ constructor(include) {
17
+ this.id = wikiparse.id++;
18
+ this.include = Boolean(include);
19
+ this.wikitext = undefined;
20
+ this.running = undefined;
21
+ }
22
+ /**
23
+ * 提交语法分析
24
+ * @param wikitext 待分析的文本
25
+ */
26
+ queue(wikitext) {
27
+ this.wikitext = wikitext;
28
+ this.running = this.lint(wikitext);
29
+ return this.running;
30
+ }
31
+ /**
32
+ * 执行语法分析
33
+ * @param wikitext 待分析的文本
34
+ */
35
+ lint(wikitext) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const { include } = this, errors = yield wikiparse.lint(wikitext, include, this.id);
38
+ return this.include === include && this.wikitext === wikitext ? errors : this.running;
39
+ });
40
+ }
41
+ }
42
+ wikiparse.Linter = Linter;
43
+ })();
@@ -0,0 +1,63 @@
1
+ .wikiparse-container {
2
+ position: relative;
3
+ -webkit-text-size-adjust: none;
4
+ }
5
+ .wikiparsed {
6
+ position: relative;
7
+ display: block;
8
+ box-sizing: border-box;
9
+ width: 100%;
10
+ resize: vertical;
11
+ font-family: monospace;
12
+ background: none !important;
13
+ caret-color: #000;
14
+ }
15
+ #wikiPretty {
16
+ position: absolute;
17
+ inset: 0;
18
+ background-color: #fff;
19
+ -webkit-user-select: none;
20
+ user-select: none;
21
+ }
22
+ #wikiPretty + .wikiparsed, #wikiPretty {
23
+ outline: none;
24
+ border: 1.5px solid #dedede !important;
25
+ border-radius: 0;
26
+ padding: .4em;
27
+ line-height: 1.4 !important;
28
+ font-size: inherit;
29
+ tab-size: 4;
30
+ overflow-y: auto;
31
+ word-break: normal;
32
+ }
33
+
34
+ /* compromise for font-weight: bold */
35
+ .wpb-ext, .wpb-html,
36
+ .wpb-arg,
37
+ .wpb-template,
38
+ .wpb-magic-word,
39
+ .wpb-heading-title,
40
+ .wpb-table, .wpb-tr, .wpb-td,
41
+ .wpb-double-underscore, .wpb-hr, .wpb-quote, .wpb-list, .wpb-dd
42
+ .wpb-converter {
43
+ -webkit-text-stroke-width: .1ex;
44
+ }
45
+ .wpb-hidden, .wpb-table-inter, .wpb-table-inter span,
46
+ .wpb-noinclude, .wpb-include, .wpb-comment,
47
+ .wpb-ext-attrs, .wpb-html-attrs,
48
+ .wpb-ext-inner,
49
+ .wpb-arg-default,
50
+ .wpb-invoke-module, .wpb-invoke-function,
51
+ .wpb-parameter,
52
+ .wpb-table-attrs, .wpb-td-inner,
53
+ .wpb-converter-rule {
54
+ -webkit-text-stroke-width: 0;
55
+ }
56
+ #wikiPretty span {
57
+ font-weight: normal;
58
+ }
59
+
60
+ #wikiPretty.active span {
61
+ color: transparent;
62
+ background: none;
63
+ }
@@ -0,0 +1,119 @@
1
+ .wikiparser {
2
+ white-space: pre-wrap;
3
+ overflow-wrap: break-word;
4
+ font-family: monospace;
5
+ }
6
+
7
+ .wpb-error {
8
+ text-decoration: underline wavy #f00 1px;
9
+ }
10
+ .wpb-hidden, .wpb-table-inter, .wpb-table-inter span {
11
+ color: #f00;
12
+ font-weight: normal;
13
+ text-decoration: underline wavy 1px;
14
+ }
15
+
16
+ .wpb-noinclude, .wpb-include, .wpb-comment {
17
+ color: #72777d;
18
+ font-weight: normal;
19
+ }
20
+ .wpb-comment {
21
+ font-style: italic;
22
+ }
23
+
24
+ .wpb-ext, .wpb-html {
25
+ color: #14866d;
26
+ font-weight: bold;
27
+ }
28
+ .wpb-ext-attrs, .wpb-html-attrs {
29
+ font-weight: normal;
30
+ }
31
+ .wpb-ext-attr > .wpb-attr-value, .wpb-html-attr > .wpb-attr-value {
32
+ color: #179b1c;
33
+ }
34
+ .wpb-ext-inner {
35
+ color: initial;
36
+ font-weight: normal;
37
+ background-color: rgba(0, 0, 0, .03);
38
+ }
39
+
40
+ .wpb-arg {
41
+ color: #ac6600;
42
+ font-weight: bold;
43
+ }
44
+ .wpb-arg-default {
45
+ color: #ad9300;
46
+ font-weight: normal;
47
+ }
48
+
49
+ .wpb-template {
50
+ color: #80c;
51
+ font-weight: bold;
52
+ background-color: rgba(119, 0, 170, .03);
53
+ }
54
+ .wpb-magic-word {
55
+ color: #d33;
56
+ font-weight: bold;
57
+ background-color: rgba(170, 17, 17, .03);
58
+ }
59
+ .wpb-invoke-module, .wpb-invoke-function {
60
+ color: #dd5d33;
61
+ font-weight: normal;
62
+ }
63
+ .wpb-parameter {
64
+ color: initial;
65
+ font-weight: normal;
66
+ }
67
+ .wpb-template > .wpb-parameter > .wpb-parameter-key,
68
+ .wpb-invoke-function ~ .wpb-parameter > .wpb-parameter-key {
69
+ color: #b0c;
70
+ }
71
+
72
+ .wpb-heading, .wpb-image-parameter {
73
+ color: #0076dd;
74
+ }
75
+ .wpb-heading-title {
76
+ color: initial;
77
+ font-weight: bold;
78
+ }
79
+
80
+ .wpb-table, .wpb-tr, .wpb-td {
81
+ color: #d08;
82
+ font-weight: bold;
83
+ }
84
+ .wpb-table-attrs {
85
+ font-weight: normal;
86
+ }
87
+ .wpb-table-attr > .wpb-attr-value {
88
+ color: #f500d4;
89
+ }
90
+ .wpb-td-inner {
91
+ color: initial;
92
+ font-weight: normal;
93
+ }
94
+
95
+ .wpb-double-underscore, .wpb-hr, .wpb-quote, .wpb-list, .wpb-dd {
96
+ color: #0076dd;
97
+ font-weight: bold;
98
+ background-color: #eee;
99
+ }
100
+
101
+ .wpb-link, .wpb-category, .wpb-file, .wpb-gallery-image, .wpb-imagemap-image,
102
+ .wpb-ext-link, .wpb-free-ext-link {
103
+ color: #000aaa;
104
+ background-color: rgba(34, 17, 153, .03);
105
+ }
106
+ .wpb-link-text, .wpb-image-caption, .wpb-ext-link-text {
107
+ color: initial;
108
+ }
109
+
110
+ .wpb-converter {
111
+ color: #b68;
112
+ font-weight: bold;
113
+ }
114
+ .wpb-converter-rule {
115
+ font-weight: normal;
116
+ }
117
+ .wpb-converter-rule-from, .wpb-converter-rule-to, .wpb-converter-noconvert {
118
+ color: initial;
119
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikiparser-node",
3
- "version": "1.0.0-beta.4",
3
+ "version": "1.0.1-b",
4
4
  "description": "A Node.js parser for MediaWiki markup with AST",
5
5
  "keywords": [
6
6
  "mediawiki",
@@ -14,36 +14,45 @@
14
14
  "license": "GPL-3.0",
15
15
  "author": "Bhsd",
16
16
  "files": [
17
- "/errors/README",
18
- "/printed/README",
17
+ "/bundle/bundle.min.js",
18
+ "/extensions/dist/",
19
+ "/extensions/*.css",
20
+ "!/extensions/dist/gh-page.js",
21
+ "!/extensions/gh-page.css",
19
22
  "/config/",
20
23
  "/i18n/",
21
- "/dist/"
24
+ "!/config/.schema.json"
22
25
  ],
23
- "main": "./dist/index.js",
26
+ "browser": "/bundle/bundle.min.js",
27
+ "main": "./bundle/bundle.js",
24
28
  "repository": {
25
29
  "type": "git",
26
30
  "url": "git+https://github.com/bhsd-harry/wikiparser-node.git"
27
31
  },
28
32
  "scripts": {
29
- "prepublishOnly": "rm -rf dist/; tsc; rm dist/internal.js; rm dist/[mpu]*/*.d.ts; grep -rl --include='*.d.ts' '@private' dist/ | xargs gsed -i '/@private/,+1d'",
30
- "build": "rm -rf dist/; tsc; grep -rl --include='*.js' '@ts' dist/ | xargs gsed -i '/@ts/d'; eslint --fix dist/",
33
+ "prepublishOnly": "webpack build --mode production && npm run build:ext",
34
+ "build:core": "rm bundle/*.js; webpack build --mode development; webpack build --mode production",
35
+ "build:ext": "rm -rf extensions/dist/; tsc --project extensions/tsconfig.json; ls extensions/dist/*.js | xargs gsed -i '/export {};/d'",
36
+ "build:test": "rm -rf dist/; tsc; gsed -i 's|./config/minimum|../config/minimum|' dist/index.js",
37
+ "build": "npm run build:core && npm run build:ext",
31
38
  "diff": "git diff --ignore-all-space --color-moved",
32
- "doc": "node ./bin/doc.js",
33
- "toc": "node ./bin/toc.js",
34
- "lint:ts": "eslint --cache --ignore-pattern '/dist/' .",
39
+ "lint:ts": "eslint --cache --ignore-pattern 'dist/' .",
35
40
  "lint:json": "ajv -s config/.schema.json -d 'config/*.json' --strict=true --strict-required=false",
36
- "lint": "npm run lint:ts && npm run lint:json",
37
- "test:real": "node test/real.js",
38
- "test:single": "node --prof test/single.js && node --prof-process isolate-0x*-v8.log > test/processed.txt && rm isolate-0x*-v8.log"
41
+ "lint:css": "stylelint extensions/*.css",
42
+ "lint": "npm run lint:ts && npm run lint:json && npm run lint:css",
43
+ "test:real": "node dist/test/real.js",
44
+ "test:single": "node dist/test/single.js"
39
45
  },
40
46
  "devDependencies": {
41
47
  "@cypress/request": "^3.0.1",
42
48
  "@types/node": "^20.9.0",
43
- "@typescript-eslint/eslint-plugin": "^5.62.0",
44
- "@typescript-eslint/parser": "^5.62.0",
49
+ "@types/request": "^2.48.12",
50
+ "@typescript-eslint/eslint-plugin": "^6.12.0",
51
+ "@typescript-eslint/parser": "^6.12.0",
45
52
  "ajv-cli": "^5.0.0",
53
+ "esbuild-loader": "^4.0.2",
46
54
  "eslint": "^8.53.0",
55
+ "eslint-plugin-es-x": "^7.3.0",
47
56
  "eslint-plugin-eslint-comments": "^3.2.0",
48
57
  "eslint-plugin-jsdoc": "^46.8.2",
49
58
  "eslint-plugin-json-es": "^1.5.7",
@@ -51,7 +60,11 @@
51
60
  "eslint-plugin-promise": "^6.1.1",
52
61
  "eslint-plugin-regexp": "^2.1.1",
53
62
  "eslint-plugin-unicorn": "^49.0.0",
54
- "typescript": "^5.0.3"
63
+ "stylelint": "^15.11.0",
64
+ "stylelint-config-recommended": "^10.0.1",
65
+ "typescript": "^5.0.3",
66
+ "webpack-cli": "^5.1.4",
67
+ "webpack": "^5.89.0"
55
68
  },
56
69
  "engines": {
57
70
  "node": "^20.9.0"
@@ -1,160 +0,0 @@
1
- {
2
- "type": "object",
3
- "properties": {
4
- "ext": {
5
- "description": "extension tags",
6
- "type": "array",
7
- "items": {
8
- "type": "string",
9
- "pattern": "^[a-z\\d_]+$"
10
- }
11
- },
12
- "html": {
13
- "description": "valid HTML tags",
14
- "type": "array",
15
- "items": {
16
- "type": "array",
17
- "items": {
18
- "type": "string",
19
- "pattern": "^[a-z\\d]+$"
20
- }
21
- },
22
- "minItems": 3,
23
- "maxItems": 3
24
- },
25
- "namespaces": {
26
- "description": "formatted namespaces",
27
- "type": "object",
28
- "patternProperties": {
29
- "^-?\\d+$": {
30
- "type": "string"
31
- }
32
- },
33
- "required": [
34
- "6",
35
- "10"
36
- ],
37
- "additionalProperties": false
38
- },
39
- "nsid": {
40
- "description": "namespace IDs",
41
- "type": "object",
42
- "additionalProperties": {
43
- "type": "integer"
44
- }
45
- },
46
- "parserFunction": {
47
- "type": "array",
48
- "items": [
49
- {
50
- "description": "case-insensitive parser functions",
51
- "type": "object",
52
- "additionalProperties": {
53
- "type": "string"
54
- }
55
- },
56
- {
57
- "description": "case-sensitive parser functions",
58
- "type": "array",
59
- "items": {
60
- "type": "string"
61
- }
62
- },
63
- {
64
- "description": "msg and raw",
65
- "type": "array",
66
- "items": {
67
- "type": "string"
68
- }
69
- },
70
- {
71
- "description": "subst and safesubst",
72
- "type": "array",
73
- "items": {
74
- "type": "string"
75
- }
76
- }
77
- ],
78
- "minItems": 4,
79
- "maxItems": 4
80
- },
81
- "doubleUnderscore": {
82
- "description": "behavior switches",
83
- "type": "array",
84
- "items": {
85
- "type": "array",
86
- "items": {
87
- "type": "string"
88
- }
89
- },
90
- "minItems": 2,
91
- "maxItems": 2
92
- },
93
- "protocol": {
94
- "description": "external link protocols",
95
- "type": "string",
96
- "pattern": "^[a-z:/]+(?:\\|[a-z:/]+)*$"
97
- },
98
- "interwiki": {
99
- "type": "array",
100
- "items": {
101
- "type": "string"
102
- }
103
- },
104
- "img": {
105
- "description": "image-related magic words",
106
- "type": "object",
107
- "additionalProperties": {
108
- "type": "string",
109
- "pattern": "^[-a-z]+$"
110
- }
111
- },
112
- "variants": {
113
- "description": "variants for language conversion",
114
- "type": "array",
115
- "items": {
116
- "type": "string",
117
- "pattern": "^[-a-z]+$"
118
- }
119
- },
120
- "conversionTable": {
121
- "description": "table of unidirectional conversions",
122
- "type": "array",
123
- "items": {
124
- "type": "array",
125
- "items": {
126
- "type": "string",
127
- "pattern": "^[^ <>[\\]{}|]+$"
128
- },
129
- "minItems": 2,
130
- "maxItems": 2
131
- }
132
- },
133
- "redirects": {
134
- "description": "table of redirects",
135
- "type": "array",
136
- "items": {
137
- "type": "array",
138
- "items": {
139
- "type": "string",
140
- "pattern": "^[^ <>[\\]{}|]+$"
141
- },
142
- "minItems": 2,
143
- "maxItems": 2
144
- }
145
- }
146
- },
147
- "required": [
148
- "ext",
149
- "html",
150
- "namespaces",
151
- "nsid",
152
- "parserFunction",
153
- "doubleUnderscore",
154
- "protocol",
155
- "interwiki",
156
- "img",
157
- "variants"
158
- ],
159
- "additionalProperties": false
160
- }