wikiparser-node 1.0.0-beta.3 → 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 (146) 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/minimum.json +136 -0
  5. package/config/moegirl.json +1 -44
  6. package/config/zhwiki.json +1 -466
  7. package/extensions/dist/base.js +105 -0
  8. package/extensions/dist/editor.js +172 -0
  9. package/extensions/dist/highlight.js +46 -0
  10. package/extensions/dist/lint.js +43 -0
  11. package/extensions/editor.css +63 -0
  12. package/extensions/ui.css +119 -0
  13. package/package.json +35 -20
  14. package/config/.schema.json +0 -160
  15. package/dist/index.d.ts +0 -62
  16. package/dist/index.js +0 -305
  17. package/dist/internal.d.ts +0 -44
  18. package/dist/lib/element.d.ts +0 -186
  19. package/dist/lib/element.js +0 -659
  20. package/dist/lib/node.d.ts +0 -178
  21. package/dist/lib/node.js +0 -458
  22. package/dist/lib/range.d.ts +0 -132
  23. package/dist/lib/range.js +0 -387
  24. package/dist/lib/ranges.d.ts +0 -28
  25. package/dist/lib/ranges.js +0 -125
  26. package/dist/lib/text.d.ts +0 -78
  27. package/dist/lib/text.js +0 -227
  28. package/dist/lib/title.d.ts +0 -33
  29. package/dist/lib/title.js +0 -110
  30. package/dist/mixin/attributesParent.js +0 -93
  31. package/dist/mixin/fixed.js +0 -32
  32. package/dist/mixin/hidden.js +0 -23
  33. package/dist/mixin/singleLine.js +0 -26
  34. package/dist/mixin/sol.js +0 -44
  35. package/dist/parser/braces.js +0 -125
  36. package/dist/parser/commentAndExt.js +0 -58
  37. package/dist/parser/converter.js +0 -38
  38. package/dist/parser/externalLinks.js +0 -28
  39. package/dist/parser/hrAndDoubleUnderscore.js +0 -40
  40. package/dist/parser/html.js +0 -38
  41. package/dist/parser/links.js +0 -94
  42. package/dist/parser/list.js +0 -61
  43. package/dist/parser/magicLinks.js +0 -39
  44. package/dist/parser/quotes.js +0 -67
  45. package/dist/parser/selector.js +0 -165
  46. package/dist/parser/table.js +0 -117
  47. package/dist/src/arg.d.ts +0 -77
  48. package/dist/src/arg.js +0 -199
  49. package/dist/src/atom.d.ts +0 -11
  50. package/dist/src/atom.js +0 -24
  51. package/dist/src/attribute.d.ts +0 -106
  52. package/dist/src/attribute.js +0 -436
  53. package/dist/src/attributes.d.ts +0 -119
  54. package/dist/src/attributes.js +0 -366
  55. package/dist/src/converter.d.ts +0 -75
  56. package/dist/src/converter.js +0 -141
  57. package/dist/src/converterFlags.d.ts +0 -107
  58. package/dist/src/converterFlags.js +0 -238
  59. package/dist/src/converterRule.d.ts +0 -96
  60. package/dist/src/converterRule.js +0 -255
  61. package/dist/src/extLink.d.ts +0 -63
  62. package/dist/src/extLink.js +0 -157
  63. package/dist/src/gallery.d.ts +0 -70
  64. package/dist/src/gallery.js +0 -137
  65. package/dist/src/heading.d.ts +0 -82
  66. package/dist/src/heading.js +0 -135
  67. package/dist/src/hidden.d.ts +0 -19
  68. package/dist/src/hidden.js +0 -26
  69. package/dist/src/html.d.ts +0 -113
  70. package/dist/src/html.js +0 -245
  71. package/dist/src/imageParameter.d.ts +0 -82
  72. package/dist/src/imageParameter.js +0 -256
  73. package/dist/src/imagemap.d.ts +0 -77
  74. package/dist/src/imagemap.js +0 -169
  75. package/dist/src/imagemapLink.d.ts +0 -48
  76. package/dist/src/imagemapLink.js +0 -43
  77. package/dist/src/index.d.ts +0 -156
  78. package/dist/src/index.js +0 -819
  79. package/dist/src/link/base.d.ts +0 -69
  80. package/dist/src/link/base.js +0 -231
  81. package/dist/src/link/category.d.ts +0 -14
  82. package/dist/src/link/category.js +0 -28
  83. package/dist/src/link/file.d.ts +0 -105
  84. package/dist/src/link/file.js +0 -269
  85. package/dist/src/link/galleryImage.d.ts +0 -37
  86. package/dist/src/link/galleryImage.js +0 -100
  87. package/dist/src/link/index.d.ts +0 -50
  88. package/dist/src/link/index.js +0 -134
  89. package/dist/src/magicLink.d.ts +0 -46
  90. package/dist/src/magicLink.js +0 -131
  91. package/dist/src/nested.d.ts +0 -47
  92. package/dist/src/nested.js +0 -92
  93. package/dist/src/nowiki/base.d.ts +0 -38
  94. package/dist/src/nowiki/base.js +0 -31
  95. package/dist/src/nowiki/comment.d.ts +0 -42
  96. package/dist/src/nowiki/comment.js +0 -64
  97. package/dist/src/nowiki/dd.d.ts +0 -22
  98. package/dist/src/nowiki/dd.js +0 -46
  99. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -35
  100. package/dist/src/nowiki/doubleUnderscore.js +0 -48
  101. package/dist/src/nowiki/hr.d.ts +0 -30
  102. package/dist/src/nowiki/hr.js +0 -36
  103. package/dist/src/nowiki/index.d.ts +0 -19
  104. package/dist/src/nowiki/index.js +0 -23
  105. package/dist/src/nowiki/list.d.ts +0 -16
  106. package/dist/src/nowiki/list.js +0 -13
  107. package/dist/src/nowiki/noinclude.d.ts +0 -21
  108. package/dist/src/nowiki/noinclude.js +0 -24
  109. package/dist/src/nowiki/quote.d.ts +0 -27
  110. package/dist/src/nowiki/quote.js +0 -58
  111. package/dist/src/onlyinclude.d.ts +0 -38
  112. package/dist/src/onlyinclude.js +0 -66
  113. package/dist/src/paramTag/index.d.ts +0 -50
  114. package/dist/src/paramTag/index.js +0 -78
  115. package/dist/src/paramTag/inputbox.d.ts +0 -7
  116. package/dist/src/paramTag/inputbox.js +0 -21
  117. package/dist/src/parameter.d.ts +0 -95
  118. package/dist/src/parameter.js +0 -204
  119. package/dist/src/pre.d.ts +0 -27
  120. package/dist/src/pre.js +0 -44
  121. package/dist/src/syntax.d.ts +0 -22
  122. package/dist/src/syntax.js +0 -67
  123. package/dist/src/table/base.d.ts +0 -60
  124. package/dist/src/table/base.js +0 -80
  125. package/dist/src/table/index.d.ts +0 -247
  126. package/dist/src/table/index.js +0 -783
  127. package/dist/src/table/td.d.ts +0 -119
  128. package/dist/src/table/td.js +0 -268
  129. package/dist/src/table/tr.d.ts +0 -31
  130. package/dist/src/table/tr.js +0 -50
  131. package/dist/src/table/trBase.d.ts +0 -62
  132. package/dist/src/table/trBase.js +0 -157
  133. package/dist/src/tagPair/ext.d.ts +0 -54
  134. package/dist/src/tagPair/ext.js +0 -150
  135. package/dist/src/tagPair/include.d.ts +0 -43
  136. package/dist/src/tagPair/include.js +0 -43
  137. package/dist/src/tagPair/index.d.ts +0 -57
  138. package/dist/src/tagPair/index.js +0 -113
  139. package/dist/src/transclude.d.ts +0 -200
  140. package/dist/src/transclude.js +0 -732
  141. package/dist/util/debug.js +0 -42
  142. package/dist/util/diff.js +0 -71
  143. package/dist/util/lint.js +0 -38
  144. package/dist/util/string.js +0 -74
  145. package/errors/README +0 -1
  146. 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.3",
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,42 +14,57 @@
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/",
31
- "doc": "node ./bin/doc.js",
32
- "toc": "node ./bin/toc.js",
33
- "lint:ts": "eslint --cache --ignore-pattern '/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",
38
+ "diff": "git diff --ignore-all-space --color-moved",
39
+ "lint:ts": "eslint --cache --ignore-pattern 'dist/' .",
34
40
  "lint:json": "ajv -s config/.schema.json -d 'config/*.json' --strict=true --strict-required=false",
35
- "lint": "npm run lint:ts && npm run lint:json",
36
- "test:real": "node test/real.js",
37
- "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"
38
45
  },
39
46
  "devDependencies": {
47
+ "@cypress/request": "^3.0.1",
40
48
  "@types/node": "^20.9.0",
49
+ "@types/request": "^2.48.12",
50
+ "@typescript-eslint/eslint-plugin": "^6.12.0",
51
+ "@typescript-eslint/parser": "^6.12.0",
52
+ "ajv-cli": "^5.0.0",
53
+ "esbuild-loader": "^4.0.2",
41
54
  "eslint": "^8.53.0",
55
+ "eslint-plugin-es-x": "^7.3.0",
56
+ "eslint-plugin-eslint-comments": "^3.2.0",
57
+ "eslint-plugin-jsdoc": "^46.8.2",
58
+ "eslint-plugin-json-es": "^1.5.7",
42
59
  "eslint-plugin-n": "^16.3.1",
60
+ "eslint-plugin-promise": "^6.1.1",
43
61
  "eslint-plugin-regexp": "^2.1.1",
44
62
  "eslint-plugin-unicorn": "^49.0.0",
45
- "eslint-plugin-jsdoc": "^46.8.2",
46
- "eslint-plugin-json-es": "^1.5.7",
47
- "eslint-plugin-eslint-comments": "^3.2.0",
63
+ "stylelint": "^15.11.0",
64
+ "stylelint-config-recommended": "^10.0.1",
48
65
  "typescript": "^5.0.3",
49
- "@typescript-eslint/eslint-plugin": "^5.62.0",
50
- "@typescript-eslint/parser": "^5.62.0",
51
- "ajv-cli": "^5.0.0",
52
- "request": "^2.88.2"
66
+ "webpack-cli": "^5.1.4",
67
+ "webpack": "^5.89.0"
53
68
  },
54
69
  "engines": {
55
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
- }