wikiparser-node 1.1.0 → 1.1.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 (153) hide show
  1. package/bundle/bundle.min.js +36 -0
  2. package/config/llwiki.json +1 -35
  3. package/config/moegirl.json +1 -44
  4. package/config/zhwiki.json +1 -466
  5. package/extensions/dist/base.js +70 -0
  6. package/extensions/dist/editor.js +172 -0
  7. package/extensions/dist/highlight.js +39 -0
  8. package/extensions/dist/lint.js +48 -0
  9. package/extensions/editor.css +63 -0
  10. package/extensions/ui.css +119 -0
  11. package/package.json +23 -11
  12. package/config/.schema.json +0 -160
  13. package/dist/addon/table.d.ts +0 -6
  14. package/dist/addon/table.js +0 -559
  15. package/dist/bin/toc.js +0 -18
  16. package/dist/index.d.ts +0 -60
  17. package/dist/index.js +0 -210
  18. package/dist/internal.d.ts +0 -44
  19. package/dist/lib/element.d.ts +0 -155
  20. package/dist/lib/element.js +0 -655
  21. package/dist/lib/node.d.ts +0 -143
  22. package/dist/lib/node.js +0 -420
  23. package/dist/lib/range.d.ts +0 -104
  24. package/dist/lib/range.js +0 -386
  25. package/dist/lib/ranges.d.ts +0 -26
  26. package/dist/lib/ranges.js +0 -117
  27. package/dist/lib/text.d.ts +0 -63
  28. package/dist/lib/text.js +0 -218
  29. package/dist/lib/title.d.ts +0 -38
  30. package/dist/lib/title.js +0 -162
  31. package/dist/mixin/attributesParent.js +0 -94
  32. package/dist/mixin/fixed.js +0 -32
  33. package/dist/mixin/flagsParent.js +0 -70
  34. package/dist/mixin/hidden.js +0 -22
  35. package/dist/mixin/magicLinkParent.js +0 -41
  36. package/dist/mixin/singleLine.js +0 -25
  37. package/dist/mixin/sol.js +0 -43
  38. package/dist/mixin/syntax.js +0 -56
  39. package/dist/parser/braces.js +0 -123
  40. package/dist/parser/commentAndExt.js +0 -69
  41. package/dist/parser/converter.js +0 -40
  42. package/dist/parser/externalLinks.js +0 -28
  43. package/dist/parser/hrAndDoubleUnderscore.js +0 -38
  44. package/dist/parser/html.js +0 -36
  45. package/dist/parser/links.js +0 -94
  46. package/dist/parser/list.js +0 -59
  47. package/dist/parser/magicLinks.js +0 -40
  48. package/dist/parser/quotes.js +0 -67
  49. package/dist/parser/selector.js +0 -163
  50. package/dist/parser/table.js +0 -110
  51. package/dist/src/arg.d.ts +0 -58
  52. package/dist/src/arg.js +0 -190
  53. package/dist/src/atom.d.ts +0 -12
  54. package/dist/src/atom.js +0 -27
  55. package/dist/src/attribute.d.ts +0 -86
  56. package/dist/src/attribute.js +0 -392
  57. package/dist/src/attributes.d.ts +0 -106
  58. package/dist/src/attributes.js +0 -339
  59. package/dist/src/converter.d.ts +0 -51
  60. package/dist/src/converter.js +0 -79
  61. package/dist/src/converterFlags.d.ts +0 -87
  62. package/dist/src/converterFlags.js +0 -223
  63. package/dist/src/converterRule.d.ts +0 -81
  64. package/dist/src/converterRule.js +0 -221
  65. package/dist/src/extLink.d.ts +0 -53
  66. package/dist/src/extLink.js +0 -121
  67. package/dist/src/gallery.d.ts +0 -55
  68. package/dist/src/gallery.js +0 -129
  69. package/dist/src/heading.d.ts +0 -76
  70. package/dist/src/heading.js +0 -127
  71. package/dist/src/hidden.d.ts +0 -21
  72. package/dist/src/hidden.js +0 -23
  73. package/dist/src/html.d.ts +0 -105
  74. package/dist/src/html.js +0 -231
  75. package/dist/src/imageParameter.d.ts +0 -66
  76. package/dist/src/imageParameter.js +0 -246
  77. package/dist/src/imagemap.d.ts +0 -57
  78. package/dist/src/imagemap.js +0 -148
  79. package/dist/src/imagemapLink.d.ts +0 -57
  80. package/dist/src/imagemapLink.js +0 -40
  81. package/dist/src/index.d.ts +0 -145
  82. package/dist/src/index.js +0 -766
  83. package/dist/src/link/base.d.ts +0 -52
  84. package/dist/src/link/base.js +0 -198
  85. package/dist/src/link/category.d.ts +0 -13
  86. package/dist/src/link/category.js +0 -29
  87. package/dist/src/link/file.d.ts +0 -96
  88. package/dist/src/link/file.js +0 -253
  89. package/dist/src/link/galleryImage.d.ts +0 -41
  90. package/dist/src/link/galleryImage.js +0 -98
  91. package/dist/src/link/index.d.ts +0 -53
  92. package/dist/src/link/index.js +0 -123
  93. package/dist/src/magicLink.d.ts +0 -58
  94. package/dist/src/magicLink.js +0 -122
  95. package/dist/src/nested.d.ts +0 -44
  96. package/dist/src/nested.js +0 -87
  97. package/dist/src/nowiki/base.d.ts +0 -46
  98. package/dist/src/nowiki/base.js +0 -42
  99. package/dist/src/nowiki/comment.d.ts +0 -39
  100. package/dist/src/nowiki/comment.js +0 -67
  101. package/dist/src/nowiki/dd.d.ts +0 -8
  102. package/dist/src/nowiki/dd.js +0 -25
  103. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -43
  104. package/dist/src/nowiki/doubleUnderscore.js +0 -51
  105. package/dist/src/nowiki/hr.d.ts +0 -29
  106. package/dist/src/nowiki/hr.js +0 -14
  107. package/dist/src/nowiki/index.d.ts +0 -16
  108. package/dist/src/nowiki/index.js +0 -21
  109. package/dist/src/nowiki/list.d.ts +0 -29
  110. package/dist/src/nowiki/list.js +0 -48
  111. package/dist/src/nowiki/listBase.d.ts +0 -18
  112. package/dist/src/nowiki/listBase.js +0 -12
  113. package/dist/src/nowiki/noinclude.d.ts +0 -25
  114. package/dist/src/nowiki/noinclude.js +0 -25
  115. package/dist/src/nowiki/quote.d.ts +0 -22
  116. package/dist/src/nowiki/quote.js +0 -50
  117. package/dist/src/onlyinclude.d.ts +0 -16
  118. package/dist/src/onlyinclude.js +0 -57
  119. package/dist/src/paramTag/index.d.ts +0 -37
  120. package/dist/src/paramTag/index.js +0 -68
  121. package/dist/src/paramTag/inputbox.d.ts +0 -8
  122. package/dist/src/paramTag/inputbox.js +0 -23
  123. package/dist/src/parameter.d.ts +0 -82
  124. package/dist/src/parameter.js +0 -202
  125. package/dist/src/pre.d.ts +0 -28
  126. package/dist/src/pre.js +0 -51
  127. package/dist/src/syntax.d.ts +0 -25
  128. package/dist/src/syntax.js +0 -30
  129. package/dist/src/table/base.d.ts +0 -52
  130. package/dist/src/table/base.js +0 -78
  131. package/dist/src/table/index.d.ts +0 -229
  132. package/dist/src/table/index.js +0 -379
  133. package/dist/src/table/td.d.ts +0 -102
  134. package/dist/src/table/td.js +0 -261
  135. package/dist/src/table/tr.d.ts +0 -32
  136. package/dist/src/table/tr.js +0 -56
  137. package/dist/src/table/trBase.d.ts +0 -54
  138. package/dist/src/table/trBase.js +0 -151
  139. package/dist/src/tagPair/ext.d.ts +0 -55
  140. package/dist/src/tagPair/ext.js +0 -142
  141. package/dist/src/tagPair/include.d.ts +0 -52
  142. package/dist/src/tagPair/include.js +0 -58
  143. package/dist/src/tagPair/index.d.ts +0 -47
  144. package/dist/src/tagPair/index.js +0 -93
  145. package/dist/src/transclude.d.ts +0 -167
  146. package/dist/src/transclude.js +0 -694
  147. package/dist/util/constants.js +0 -109
  148. package/dist/util/debug.js +0 -65
  149. package/dist/util/diff.js +0 -74
  150. package/dist/util/lint.js +0 -50
  151. package/dist/util/string.js +0 -65
  152. package/errors/README +0 -1
  153. 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
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
11
+ if (kind === "m") throw new TypeError("Private method is not writable");
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
13
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
14
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
15
+ };
16
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
17
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
18
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
19
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
20
+ };
21
+ (() => {
22
+ var _Printer_instances, _Printer_id, _Printer_preview, _Printer_textbox, _Printer_root, _Printer_viewportChanged, _Printer_tick, _Printer_paint;
23
+ const { wikiparse } = window, { MAX_STAGE } = wikiparse;
24
+ class Printer {
25
+ constructor(preview, textbox, include) {
26
+ _Printer_instances.add(this);
27
+ _Printer_id.set(this, void 0);
28
+ _Printer_preview.set(this, void 0);
29
+ _Printer_textbox.set(this, void 0);
30
+ _Printer_root.set(this, void 0);
31
+ _Printer_viewportChanged.set(this, void 0);
32
+ __classPrivateFieldSet(this, _Printer_id, wikiparse.id++, "f");
33
+ __classPrivateFieldSet(this, _Printer_preview, preview, "f");
34
+ __classPrivateFieldSet(this, _Printer_textbox, textbox, "f");
35
+ __classPrivateFieldSet(this, _Printer_root, [], "f");
36
+ __classPrivateFieldSet(this, _Printer_viewportChanged, false, "f");
37
+ this.include = Boolean(include);
38
+ this.running = undefined;
39
+ this.ticks = [0, undefined];
40
+ }
41
+ queue(delay, method) {
42
+ const { ticks } = this, [state] = ticks;
43
+ if (state <= 0 || method === 'coarsePrint' || ticks[1] !== 'coarsePrint') {
44
+ ticks[0] = delay;
45
+ ticks[1] = method;
46
+ if (state <= 0) {
47
+ __classPrivateFieldGet(this, _Printer_instances, "m", _Printer_tick).call(this);
48
+ }
49
+ }
50
+ }
51
+ coarsePrint() {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ if (this.running) {
54
+ return undefined;
55
+ }
56
+ const { include } = this, { value } = __classPrivateFieldGet(this, _Printer_textbox, "f"), parsed = yield wikiparse.print(value, include, 2, __classPrivateFieldGet(this, _Printer_id, "f"));
57
+ if (this.include !== include || __classPrivateFieldGet(this, _Printer_textbox, "f").value !== value) {
58
+ this.running = undefined;
59
+ this.running = this.coarsePrint();
60
+ return this.running;
61
+ }
62
+ __classPrivateFieldSet(this, _Printer_root, parsed, "f");
63
+ __classPrivateFieldGet(this, _Printer_instances, "m", _Printer_paint).call(this);
64
+ this.running = undefined;
65
+ this.running = this.finePrint();
66
+ return this.running;
67
+ });
68
+ }
69
+ finePrint() {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ if (this.running) {
72
+ __classPrivateFieldSet(this, _Printer_viewportChanged, true, "f");
73
+ return undefined;
74
+ }
75
+ __classPrivateFieldSet(this, _Printer_viewportChanged, false, "f");
76
+ const { include } = this, { value } = __classPrivateFieldGet(this, _Printer_textbox, "f"), { scrollHeight, offsetHeight: parentHeight, scrollTop, children: [rootNode] } = __classPrivateFieldGet(this, _Printer_preview, "f");
77
+ let text = value, start = 0, { length: end } = __classPrivateFieldGet(this, _Printer_root, "f");
78
+ if (scrollHeight > parentHeight) {
79
+ const childNodes = [...rootNode.childNodes], headings = childNodes.filter(({ className }) => className === 'wpb-heading'), { length } = headings;
80
+ if (length > 0) {
81
+ let i = headings.findIndex(({ offsetTop, offsetHeight }) => offsetTop + offsetHeight > scrollTop);
82
+ i = i === -1 ? length : i;
83
+ let j = headings.slice(i).findIndex(({ offsetTop }) => offsetTop >= scrollTop + parentHeight);
84
+ j = j === -1 ? length : i + j;
85
+ start = i ? childNodes.indexOf(headings[i - 1]) : 0;
86
+ while (i <= j && __classPrivateFieldGet(this, _Printer_root, "f")[start][0] === MAX_STAGE) {
87
+ start = childNodes.indexOf(headings[i++]);
88
+ }
89
+ end = j === length ? end : childNodes.indexOf(headings[j]);
90
+ while (i <= j && __classPrivateFieldGet(this, _Printer_root, "f")[end - 1][0] === MAX_STAGE) {
91
+ end = childNodes.indexOf(headings[--j]);
92
+ }
93
+ text = __classPrivateFieldGet(this, _Printer_root, "f").slice(start, end).map(([, str]) => str).join('');
94
+ }
95
+ }
96
+ if (start === end) {
97
+ this.running = undefined;
98
+ return undefined;
99
+ }
100
+ const parsed = yield wikiparse.print(text, include, MAX_STAGE, __classPrivateFieldGet(this, _Printer_id, "f"));
101
+ if (this.include === include && __classPrivateFieldGet(this, _Printer_textbox, "f").value === value) {
102
+ __classPrivateFieldGet(this, _Printer_root, "f").splice(start, end - start, ...parsed);
103
+ __classPrivateFieldGet(this, _Printer_instances, "m", _Printer_paint).call(this);
104
+ this.running = undefined;
105
+ if (__classPrivateFieldGet(this, _Printer_viewportChanged, "f")) {
106
+ this.running = this.finePrint();
107
+ }
108
+ }
109
+ else {
110
+ this.running = undefined;
111
+ this.running = this.coarsePrint();
112
+ }
113
+ return this.running;
114
+ });
115
+ }
116
+ }
117
+ _Printer_id = new WeakMap(), _Printer_preview = new WeakMap(), _Printer_textbox = new WeakMap(), _Printer_root = new WeakMap(), _Printer_viewportChanged = new WeakMap(), _Printer_instances = new WeakSet(), _Printer_tick = function _Printer_tick() {
118
+ setTimeout(() => {
119
+ const { ticks } = this, [t, method] = ticks;
120
+ if (t > 0) {
121
+ ticks[0] -= 500;
122
+ if (t <= 500) {
123
+ this[method]();
124
+ }
125
+ else {
126
+ __classPrivateFieldGet(this, _Printer_instances, "m", _Printer_tick).call(this);
127
+ }
128
+ }
129
+ }, 500);
130
+ }, _Printer_paint = function _Printer_paint() {
131
+ __classPrivateFieldGet(this, _Printer_preview, "f").innerHTML = `<span class="wpb-root">${__classPrivateFieldGet(this, _Printer_root, "f").map(([, , printed]) => printed).join('')}</span> `;
132
+ __classPrivateFieldGet(this, _Printer_preview, "f").scrollTop = __classPrivateFieldGet(this, _Printer_textbox, "f").scrollTop;
133
+ __classPrivateFieldGet(this, _Printer_preview, "f").classList.remove('active');
134
+ __classPrivateFieldGet(this, _Printer_textbox, "f").style.color = 'transparent';
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,39 @@
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
+ const highlight = (ele, linenums, start = 1) => __awaiter(void 0, void 0, void 0, function* () {
13
+ if (ele.classList.contains('highlighted')) {
14
+ return;
15
+ }
16
+ const html = (yield wikiparse.print(ele.innerText)).map(([, , printed]) => printed).join('');
17
+ ele.classList.add('highlighted');
18
+ if (linenums) {
19
+ const lines = html.split('\n').map((line, i) => {
20
+ const li = document.createElement('li');
21
+ li.id = `L${i + start}`;
22
+ li.innerHTML = line;
23
+ return li;
24
+ });
25
+ if (!lines[lines.length - 1].textContent) {
26
+ lines.pop();
27
+ }
28
+ const ol = document.createElement('ol');
29
+ ol.start = start;
30
+ ol.style.paddingLeft = `${String(lines.length + start - 1).length + 2.5}ch`;
31
+ ol.append(...lines);
32
+ ele.replaceChildren(ol);
33
+ }
34
+ else {
35
+ ele.innerHTML = html;
36
+ }
37
+ });
38
+ wikiparse.highlight = highlight;
39
+ })();
@@ -0,0 +1,48 @@
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
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
11
+ if (kind === "m") throw new TypeError("Private method is not writable");
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
13
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
14
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
15
+ };
16
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
17
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
18
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
19
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
20
+ };
21
+ (() => {
22
+ var _Linter_instances, _Linter_id, _Linter_wikitext, _Linter_running, _Linter_lint;
23
+ const { wikiparse } = window;
24
+ class Linter {
25
+ constructor(include) {
26
+ _Linter_instances.add(this);
27
+ _Linter_id.set(this, void 0);
28
+ _Linter_wikitext.set(this, void 0);
29
+ _Linter_running.set(this, void 0);
30
+ __classPrivateFieldSet(this, _Linter_id, wikiparse.id++, "f");
31
+ __classPrivateFieldSet(this, _Linter_wikitext, undefined, "f");
32
+ __classPrivateFieldSet(this, _Linter_running, undefined, "f");
33
+ this.include = Boolean(include);
34
+ }
35
+ queue(wikitext) {
36
+ __classPrivateFieldSet(this, _Linter_wikitext, wikitext, "f");
37
+ __classPrivateFieldSet(this, _Linter_running, __classPrivateFieldGet(this, _Linter_instances, "m", _Linter_lint).call(this, wikitext), "f");
38
+ return __classPrivateFieldGet(this, _Linter_running, "f");
39
+ }
40
+ }
41
+ _Linter_id = new WeakMap(), _Linter_wikitext = new WeakMap(), _Linter_running = new WeakMap(), _Linter_instances = new WeakSet(), _Linter_lint = function _Linter_lint(wikitext) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const { include } = this, errors = yield wikiparse.lint(wikitext, include, __classPrivateFieldGet(this, _Linter_id, "f"));
44
+ return this.include === include && __classPrivateFieldGet(this, _Linter_wikitext, "f") === wikitext ? errors : __classPrivateFieldGet(this, _Linter_running, "f");
45
+ });
46
+ };
47
+ wikiparse.Linter = Linter;
48
+ })();
@@ -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.1.0",
3
+ "version": "1.1.1-b",
4
4
  "description": "A Node.js parser for MediaWiki markup with AST",
5
5
  "keywords": [
6
6
  "mediawiki",
@@ -14,28 +14,34 @@
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
- "toc": "node ./dist/bin/toc.js",
30
- "prepublishOnly": "npm run build; rm dist/internal.js; rm -r dist/test; rm dist/[bmpu]*/*.d.ts; grep -rl --include='*.d.ts' '@private' dist/ | xargs gsed -i '/@private/,+1d'",
31
- "build": "rm -rf dist/; tsc; grep -rl --include='*.d.ts' '@private' dist/ | xargs gsed -i '/@private/,+1d'",
33
+ "prepublishOnly": "webpack build --mode production && npm run build:ext",
34
+ "build:core": "rm bundle/*.js; webpack build --mode development; webpack build --mode production; eslint --no-eslintrc -c .eslintrc.browser.json bundle/",
35
+ "build:ext": "rm -rf extensions/dist/; tsc --project extensions/tsconfig.json; ls extensions/dist/*.js | xargs gsed -i '/export {};/d'; eslint --no-eslintrc -c .eslintrc.browser.json extensions/dist/",
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",
32
38
  "diff": "git diff --ignore-all-space --color-moved",
33
39
  "lint:ts": "tsc --noEmit && eslint --cache .",
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": "node dist/test/test.js",
41
+ "lint:css": "stylelint extensions/*.css",
42
+ "lint": "npm run lint:ts && npm run lint:json && npm run lint:css",
37
43
  "test:real": "node dist/test/real.js",
38
- "test:single": "node dist/test/single.js; node --prof dist/test/single.js && node --prof-process isolate-0x*-v8.log > test/processed.txt && rm isolate-0x*-v8.log"
44
+ "test:single": "node dist/test/single.js"
39
45
  },
40
46
  "devDependencies": {
41
47
  "@cypress/request": "^3.0.1",
@@ -44,7 +50,9 @@
44
50
  "@typescript-eslint/eslint-plugin": "^6.12.0",
45
51
  "@typescript-eslint/parser": "^6.12.0",
46
52
  "ajv-cli": "^5.0.0",
53
+ "esbuild-loader": "^4.0.2",
47
54
  "eslint": "^8.53.0",
55
+ "eslint-plugin-es-x": "^7.3.0",
48
56
  "eslint-plugin-eslint-comments": "^3.2.0",
49
57
  "eslint-plugin-jsdoc": "^46.8.2",
50
58
  "eslint-plugin-json-es": "^1.5.7",
@@ -52,6 +60,10 @@
52
60
  "eslint-plugin-promise": "^6.1.1",
53
61
  "eslint-plugin-regexp": "^2.1.1",
54
62
  "eslint-plugin-unicorn": "^49.0.0",
63
+ "stylelint": "^15.11.0",
64
+ "stylelint-config-recommended": "^13.0.0",
65
+ "webpack-cli": "^5.1.4",
66
+ "webpack": "^5.89.0",
55
67
  "typescript": "^5.1.6"
56
68
  },
57
69
  "engines": {
@@ -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
- }
@@ -1,6 +0,0 @@
1
- import type { TableCoords } from '../src/table/trBase';
2
- /** @extends {Array<TableCoords[]>} */
3
- export declare class Layout extends Array<TableCoords[]> {
4
- /** 打印表格布局 */
5
- print(): void;
6
- }