wikiparser-node 1.16.3 → 1.16.5

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 (154) hide show
  1. package/README.md +1 -1
  2. package/bundle/bundle.es7.js +28 -28
  3. package/bundle/bundle.lsp.js +30 -30
  4. package/bundle/bundle.min.js +29 -29
  5. package/coverage/badge.svg +1 -1
  6. package/data/signatures.json +43 -0
  7. package/dist/addon/table.js +7 -4
  8. package/dist/addon/token.js +119 -113
  9. package/dist/addon/transclude.js +7 -5
  10. package/dist/base.d.mts +99 -30
  11. package/dist/base.d.ts +99 -30
  12. package/dist/index.d.ts +10 -4
  13. package/dist/index.js +59 -14
  14. package/dist/lib/attributes.js +2 -2
  15. package/dist/lib/element.d.ts +128 -29
  16. package/dist/lib/element.js +178 -32
  17. package/dist/lib/lsp.d.ts +62 -27
  18. package/dist/lib/lsp.js +395 -304
  19. package/dist/lib/node.d.ts +123 -54
  20. package/dist/lib/node.js +216 -87
  21. package/dist/lib/range.d.ts +83 -31
  22. package/dist/lib/range.js +83 -31
  23. package/dist/lib/ranges.d.ts +1 -1
  24. package/dist/lib/ranges.js +3 -2
  25. package/dist/lib/text.d.ts +40 -14
  26. package/dist/lib/text.js +47 -19
  27. package/dist/lib/title.d.ts +54 -17
  28. package/dist/lib/title.js +101 -47
  29. package/dist/mixin/attributesParent.d.ts +37 -21
  30. package/dist/mixin/attributesParent.js +18 -20
  31. package/dist/mixin/flagsParent.d.ts +38 -12
  32. package/dist/mixin/hidden.d.ts +0 -2
  33. package/dist/mixin/hidden.js +0 -2
  34. package/dist/mixin/magicLinkParent.d.ts +11 -5
  35. package/dist/mixin/singleLine.d.ts +0 -2
  36. package/dist/mixin/singleLine.js +3 -3
  37. package/dist/mixin/sol.d.ts +0 -2
  38. package/dist/mixin/sol.js +2 -3
  39. package/dist/mixin/syntax.d.ts +0 -2
  40. package/dist/mixin/syntax.js +0 -2
  41. package/dist/parser/braces.js +4 -2
  42. package/dist/parser/links.js +13 -7
  43. package/dist/parser/list.js +3 -1
  44. package/dist/parser/quotes.js +22 -2
  45. package/dist/parser/redirect.js +4 -1
  46. package/dist/parser/selector.js +1 -1
  47. package/dist/src/arg.d.ts +19 -9
  48. package/dist/src/arg.js +34 -15
  49. package/dist/src/atom.d.ts +5 -1
  50. package/dist/src/atom.js +5 -1
  51. package/dist/src/attribute.d.ts +26 -8
  52. package/dist/src/attribute.js +30 -11
  53. package/dist/src/attributes.d.ts +50 -22
  54. package/dist/src/attributes.js +54 -26
  55. package/dist/src/converter.d.ts +4 -2
  56. package/dist/src/converter.js +12 -9
  57. package/dist/src/converterFlags.d.ts +45 -15
  58. package/dist/src/converterFlags.js +45 -15
  59. package/dist/src/converterRule.d.ts +30 -11
  60. package/dist/src/converterRule.js +46 -16
  61. package/dist/src/extLink.d.ts +6 -2
  62. package/dist/src/extLink.js +14 -11
  63. package/dist/src/gallery.d.ts +13 -9
  64. package/dist/src/gallery.js +35 -21
  65. package/dist/src/heading.d.ts +13 -7
  66. package/dist/src/heading.js +28 -18
  67. package/dist/src/hidden.d.ts +5 -1
  68. package/dist/src/hidden.js +7 -3
  69. package/dist/src/html.d.ts +12 -10
  70. package/dist/src/html.js +17 -12
  71. package/dist/src/imageParameter.d.ts +27 -12
  72. package/dist/src/imageParameter.js +27 -12
  73. package/dist/src/imagemap.d.ts +4 -4
  74. package/dist/src/imagemap.js +9 -5
  75. package/dist/src/imagemapLink.d.ts +3 -1
  76. package/dist/src/imagemapLink.js +3 -1
  77. package/dist/src/index.d.ts +65 -64
  78. package/dist/src/index.js +111 -132
  79. package/dist/src/link/base.d.ts +14 -6
  80. package/dist/src/link/base.js +45 -21
  81. package/dist/src/link/category.d.ts +9 -4
  82. package/dist/src/link/category.js +20 -4
  83. package/dist/src/link/file.d.ts +71 -23
  84. package/dist/src/link/file.js +100 -36
  85. package/dist/src/link/galleryImage.d.ts +8 -4
  86. package/dist/src/link/galleryImage.js +15 -8
  87. package/dist/src/link/index.d.ts +14 -6
  88. package/dist/src/link/index.js +15 -5
  89. package/dist/src/link/redirectTarget.d.ts +4 -3
  90. package/dist/src/link/redirectTarget.js +5 -3
  91. package/dist/src/magicLink.d.ts +28 -12
  92. package/dist/src/magicLink.js +56 -34
  93. package/dist/src/nested.d.ts +5 -3
  94. package/dist/src/nested.js +9 -6
  95. package/dist/src/nowiki/base.d.ts +4 -2
  96. package/dist/src/nowiki/base.js +6 -5
  97. package/dist/src/nowiki/comment.d.ts +6 -2
  98. package/dist/src/nowiki/comment.js +8 -3
  99. package/dist/src/nowiki/dd.d.ts +0 -3
  100. package/dist/src/nowiki/dd.js +0 -8
  101. package/dist/src/nowiki/doubleUnderscore.d.ts +5 -1
  102. package/dist/src/nowiki/doubleUnderscore.js +5 -1
  103. package/dist/src/nowiki/index.d.ts +5 -1
  104. package/dist/src/nowiki/index.js +5 -1
  105. package/dist/src/nowiki/list.d.ts +5 -1
  106. package/dist/src/nowiki/list.js +5 -1
  107. package/dist/src/nowiki/listBase.d.ts +15 -5
  108. package/dist/src/nowiki/listBase.js +41 -10
  109. package/dist/src/nowiki/noinclude.d.ts +5 -1
  110. package/dist/src/nowiki/noinclude.js +5 -1
  111. package/dist/src/nowiki/quote.d.ts +15 -8
  112. package/dist/src/nowiki/quote.js +32 -12
  113. package/dist/src/onlyinclude.d.ts +4 -2
  114. package/dist/src/onlyinclude.js +4 -2
  115. package/dist/src/paramTag/index.d.ts +1 -1
  116. package/dist/src/paramTag/index.js +1 -1
  117. package/dist/src/parameter.d.ts +24 -12
  118. package/dist/src/parameter.js +45 -27
  119. package/dist/src/pre.d.ts +1 -1
  120. package/dist/src/pre.js +1 -1
  121. package/dist/src/redirect.d.ts +2 -0
  122. package/dist/src/redirect.js +2 -0
  123. package/dist/src/syntax.d.ts +5 -1
  124. package/dist/src/syntax.js +5 -1
  125. package/dist/src/table/base.d.ts +5 -1
  126. package/dist/src/table/base.js +11 -4
  127. package/dist/src/table/index.d.ts +134 -66
  128. package/dist/src/table/index.js +149 -81
  129. package/dist/src/table/td.d.ts +18 -10
  130. package/dist/src/table/td.js +23 -15
  131. package/dist/src/table/tr.d.ts +13 -3
  132. package/dist/src/table/tr.js +14 -6
  133. package/dist/src/table/trBase.d.ts +28 -12
  134. package/dist/src/table/trBase.js +28 -18
  135. package/dist/src/tagPair/ext.d.ts +3 -1
  136. package/dist/src/tagPair/ext.js +11 -10
  137. package/dist/src/tagPair/include.d.ts +8 -2
  138. package/dist/src/tagPair/include.js +8 -2
  139. package/dist/src/tagPair/index.d.ts +6 -2
  140. package/dist/src/tagPair/index.js +6 -2
  141. package/dist/src/transclude.d.ts +107 -33
  142. package/dist/src/transclude.js +139 -45
  143. package/dist/util/debug.js +2 -7
  144. package/dist/util/html.js +1 -14
  145. package/dist/util/string.js +7 -1
  146. package/extensions/dist/base.js +25 -8
  147. package/extensions/dist/codejar.js +2 -1
  148. package/extensions/dist/lsp.js +5 -10
  149. package/extensions/es7/base.js +25 -8
  150. package/extensions/ui.css +1 -162
  151. package/i18n/zh-hans.json +1 -1
  152. package/i18n/zh-hant.json +1 -1
  153. package/package.json +3 -3
  154. package/extensions/dist/test-page.js +0 -89
@@ -9,12 +9,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  var _a;
12
- const version = '1.16.3', src = (_a = document.currentScript) === null || _a === void 0 ? void 0 : _a.src, file = /\/extensions\/dist\/base\.(?:min\.)?js$/u, CDN = src && file.test(src)
12
+ const version = '1.16.5', src = (_a = document.currentScript) === null || _a === void 0 ? void 0 : _a.src, file = /\/extensions\/dist\/base\.(?:min\.)?js$/u, CDN = src && file.test(src)
13
13
  ? src.replace(file, '')
14
14
  : `https://testingcf.jsdelivr.net/npm/wikiparser-node@${version}`;
15
15
  const workerJS = () => {
16
16
  importScripts('$CDN/bundle/bundle.es7.js');
17
- const entities = { '&': 'amp', '<': 'lt', '>': 'gt' }, lsps = new Map();
17
+ const entities = { '&': 'amp', '<': 'lt', '>': 'gt' }, lsps = new Map(), last = { include: true };
18
+ const parse = (wikitext, include = false, stage) => {
19
+ if (stage === undefined && last.wikitext === wikitext && last.include === include) {
20
+ return last.root;
21
+ }
22
+ const root = Parser.parse(wikitext, include, stage);
23
+ if (stage === undefined) {
24
+ last.wikitext = wikitext;
25
+ last.include = include;
26
+ last.root = root;
27
+ }
28
+ return root;
29
+ };
18
30
  const getLSP = (qid, signature) => {
19
31
  let id = Math.floor(qid);
20
32
  if (signature) {
@@ -35,10 +47,12 @@ const workerJS = () => {
35
47
  parseInt(short ? s.charAt(1).repeat(2) : s.slice(1, 3), 16),
36
48
  parseInt(short ? s.charAt(2).repeat(2) : s.slice(3, 5), 16),
37
49
  parseInt(short ? s.charAt(3).repeat(2) : s.slice(5, 7), 16),
38
- parseInt((short ? s.charAt(4).repeat(2) : s.slice(7, 9)) || 'ff', 16) / 255,
50
+ parseInt((short ? s.charAt(4).repeat(2) : s.slice(7, 9)) || 'ff', 16)
51
+ / 255,
39
52
  ];
40
53
  }
41
- const values = s.slice(s.indexOf('(') + 1, -1).trim().split(/\s+(?:[,/]\s*)?|[,/]\s*/u)
54
+ const values = s.slice(s.indexOf('(') + 1, -1).trim()
55
+ .split(/\s+(?:[,/]\s*)?|[,/]\s*/u)
42
56
  .map(v => parseFloat(v) / (v.endsWith('%') ? 100 : 1));
43
57
  return [
44
58
  values[0],
@@ -55,20 +69,21 @@ const workerJS = () => {
55
69
  break;
56
70
  case 'setConfig':
57
71
  Parser.config = qid;
72
+ delete last.wikitext;
58
73
  break;
59
74
  case 'getConfig':
60
75
  postMessage([qid, Parser.getConfig()]);
61
76
  break;
62
77
  case 'json':
63
- postMessage([qid, Parser.parse(wikitext, include, stage).json()]);
78
+ postMessage([qid, parse(wikitext, include, stage).json()]);
64
79
  break;
65
80
  case 'lint':
66
- postMessage([qid, Parser.parse(wikitext, include).lint(), wikitext]);
81
+ postMessage([qid, parse(wikitext, include).lint(), wikitext]);
67
82
  break;
68
83
  case 'print':
69
84
  postMessage([
70
85
  qid,
71
- Parser.parse(wikitext, include, stage).childNodes.map(child => [
86
+ parse(wikitext, include, stage).childNodes.map(child => [
72
87
  stage !== null && stage !== void 0 ? stage : Infinity,
73
88
  String(child),
74
89
  child.type === 'text'
@@ -194,7 +209,9 @@ const splitNewLine = (html) => {
194
209
  cur.append(child.cloneNode(true));
195
210
  continue;
196
211
  }
197
- const lines = child.nodeType === Node.TEXT_NODE ? textContent.split('\n') : splitNewLine(child);
212
+ const lines = child.nodeType === Node.TEXT_NODE
213
+ ? textContent.split('\n')
214
+ : splitNewLine(child);
198
215
  append(cur, lines[0]);
199
216
  for (const text of lines.slice(1)) {
200
217
  cur = html.cloneNode();
package/extensions/ui.css CHANGED
@@ -1,162 +1 @@
1
- .wikiparse-container {
2
- position: relative;
3
- -webkit-text-size-adjust: none;
4
- }
5
- .wikiparser {
6
- white-space: pre-wrap;
7
- overflow-wrap: break-word;
8
- word-break: break-all;
9
- font-family: monospace;
10
- border: 1.5px solid #dedede;
11
- background-color: #fff;
12
- }
13
- /* wikiparse.highlight或wikiparse.codejar */
14
- .wikiparser.wikiparse-container {
15
- padding: 4px 0;
16
- overflow-y: auto;
17
- }
18
- .wikiparse-container > .wpb-root {
19
- padding: 0 6px;
20
- display: block;
21
- position: relative;
22
- overflow-y: hidden !important;
23
- }
24
-
25
- .wikiparser-line-numbers {
26
- position: absolute;
27
- top: 0;
28
- left: 0;
29
- display: inline-block;
30
- background-color: #f5f5f5;
31
- color: #6c6c6c;
32
- border-right: 1px solid #ddd;
33
- padding: 4px 0;
34
- }
35
- .wikiparser-line-numbers > span {
36
- display: inline-block;
37
- width: calc(100% - .5ch);
38
- text-align: right;
39
- }
40
- .wikiparser-sizer {
41
- position: absolute;
42
- top: 0;
43
- left: 0;
44
- right: 0;
45
- visibility: hidden;
46
- z-index: -1;
47
- padding: 0 6px;
48
- }
49
- .wpb-root[contenteditable] > .wikiparser-sizer {
50
- overflow-y: scroll;
51
- }
52
-
53
- .wpb-table-inter {
54
- color: #d73333;
55
- font-weight: normal;
56
- text-decoration: underline wavy 1px;
57
- }
58
-
59
- .wpb-hidden, .wpb-noinclude, .wpb-include, .wpb-comment, .wpb-attr-dirty {
60
- color: #7b8c8f;
61
- font-weight: normal;
62
- font-style: italic;
63
- }
64
-
65
- .wpb-ext, .wpb-html {
66
- color: #14866d;
67
- font-weight: bold;
68
- }
69
- .wpb-ext-attrs, .wpb-html-attrs {
70
- font-weight: normal;
71
- }
72
- .wpb-ext-attr > .wpb-attr-value, .wpb-html-attr > .wpb-attr-value {
73
- color: #179b1c;
74
- }
75
- .wpb-ext-inner {
76
- color: initial;
77
- font-weight: normal;
78
- background-color: rgba(0, 0, 0, .03);
79
- }
80
-
81
- .wpb-arg {
82
- color: #ac6600;
83
- font-weight: bold;
84
- }
85
- .wpb-arg-default {
86
- color: #ad9300;
87
- font-weight: normal;
88
- }
89
-
90
- .wpb-template {
91
- color: #80c;
92
- font-weight: bold;
93
- background-color: rgba(119, 0, 170, .03);
94
- }
95
- .wpb-magic-word {
96
- color: #a11;
97
- font-weight: bold;
98
- background-color: rgba(170, 17, 17, .03);
99
- }
100
- .wpb-invoke-module, .wpb-invoke-function {
101
- color: #bf3e13;
102
- font-weight: normal;
103
- }
104
- .wpb-parameter {
105
- font-weight: normal;
106
- }
107
- .wpb-template > .wpb-parameter,
108
- .wpb-invoke-function ~ .wpb-parameter {
109
- color: #b0c;
110
- }
111
- .wpb-parameter-value {
112
- color: initial;
113
- }
114
-
115
- .wpb-heading, .wpb-image-parameter {
116
- color: #0076dd;
117
- }
118
- .wpb-heading-title {
119
- color: initial;
120
- font-weight: bold;
121
- }
122
-
123
- .wpb-table, .wpb-tr, .wpb-td {
124
- color: #d08;
125
- font-weight: bold;
126
- }
127
- .wpb-table-attrs {
128
- font-weight: normal;
129
- }
130
- .wpb-table-attr > .wpb-attr-value {
131
- color: #f500d4;
132
- }
133
- .wpb-td-inner {
134
- color: initial;
135
- font-weight: normal;
136
- }
137
-
138
- .wpb-double-underscore, .wpb-hr, .wpb-quote, .wpb-list, .wpb-dd, .wpb-redirect-syntax {
139
- color: #0076dd;
140
- font-weight: bold;
141
- background-color: #eee;
142
- }
143
-
144
- .wpb-link, .wpb-category, .wpb-file, .wpb-gallery-image, .wpb-imagemap-image, .wpb-redirect-target,
145
- .wpb-ext-link, .wpb-free-ext-link, .wpb-magic-link {
146
- color: #000aaa;
147
- background-color: rgba(34, 17, 153, .03);
148
- }
149
- .wpb-link-text, .wpb-image-caption, .wpb-ext-link-text {
150
- color: initial;
151
- }
152
-
153
- .wpb-converter {
154
- color: #b68;
155
- font-weight: bold;
156
- }
157
- .wpb-converter-rule {
158
- font-weight: normal;
159
- }
160
- .wpb-converter-rule-from, .wpb-converter-rule-to, .wpb-converter-noconvert {
161
- color: initial;
162
- }
1
+ .wikiparse-container{position:relative;-webkit-text-size-adjust:none}.wikiparser{white-space:pre-wrap;overflow-wrap:break-word;word-break:break-all;font-family:monospace;border:1.5px solid #dedede;background-color:#fff}.wikiparser.wikiparse-container{padding:4px 0;overflow-y:auto}.wikiparse-container>.wpb-root{padding:0 6px;display:block;position:relative;overflow-y:hidden!important}.wikiparser-line-numbers{position:absolute;top:0;left:0;display:inline-block;background-color:#f5f5f5;color:#6c6c6c;border-right:1px solid #ddd;padding:4px 0}.wikiparser-line-numbers>span{display:inline-block;width:calc(100% - .5ch);text-align:right}.wikiparser-sizer{position:absolute;top:0;left:0;right:0;visibility:hidden;z-index:-1;padding:0 6px}.wpb-root[contenteditable]>.wikiparser-sizer{overflow-y:scroll}.wpb-table-inter{color:#d73333;font-weight:400;text-decoration:underline wavy 1px}.wpb-hidden,.wpb-noinclude,.wpb-include,.wpb-comment,.wpb-attr-dirty{color:#7b8c8f;font-weight:400;font-style:italic}.wpb-ext,.wpb-html{color:#14866d;font-weight:700}.wpb-ext-attrs,.wpb-html-attrs{font-weight:400}.wpb-ext-attr>.wpb-attr-value,.wpb-html-attr>.wpb-attr-value{color:#179b1c}.wpb-ext-inner{color:initial;font-weight:400;background-color:#00000008}.wpb-arg{color:#ac6600;font-weight:700}.wpb-arg-default{color:#ad9300;font-weight:400}.wpb-template{color:#80c;font-weight:700;background-color:#7700aa08}.wpb-magic-word{color:#a11;font-weight:700;background-color:#aa111108}.wpb-invoke-module,.wpb-invoke-function{color:#bf3e13;font-weight:400}.wpb-parameter{font-weight:400}.wpb-template>.wpb-parameter,.wpb-invoke-function~.wpb-parameter{color:#b0c}.wpb-parameter-value{color:initial}.wpb-heading,.wpb-image-parameter{color:#0076dd}.wpb-heading-title{color:initial;font-weight:700}.wpb-table,.wpb-tr,.wpb-td{color:#d08;font-weight:700}.wpb-table-attrs{font-weight:400}.wpb-table-attr>.wpb-attr-value{color:#f500d4}.wpb-td-inner{color:initial;font-weight:400}.wpb-double-underscore,.wpb-hr,.wpb-quote,.wpb-list,.wpb-dd,.wpb-redirect-syntax{color:#0076dd;font-weight:700;background-color:#eee}.wpb-link,.wpb-category,.wpb-file,.wpb-gallery-image,.wpb-imagemap-image,.wpb-redirect-target,.wpb-ext-link,.wpb-free-ext-link,.wpb-magic-link{color:#000aaa;background-color:#22119908}.wpb-link-text,.wpb-image-caption,.wpb-ext-link-text{color:initial}.wpb-converter{color:#b68;font-weight:700}.wpb-converter-rule{font-weight:400}.wpb-converter-rule-from,.wpb-converter-rule-to,.wpb-converter-noconvert{color:initial}
package/i18n/zh-hans.json CHANGED
@@ -42,7 +42,7 @@
42
42
  "obsolete attribute": "过时的属性",
43
43
  "obsolete HTML tag": "过时的HTML标签",
44
44
  "quotes": "引号",
45
- "section header in a HTML tag": "HTML标签属性中的段落标题",
45
+ "section header in an HTML tag": "HTML标签属性中的段落标题",
46
46
  "table": "表格",
47
47
  "tag that is both closing and self-closing": "同时闭合和自封闭的标签",
48
48
  "template in an internal link target": "内链目标包含模板",
package/i18n/zh-hant.json CHANGED
@@ -42,7 +42,7 @@
42
42
  "obsolete attribute": "過時的屬性",
43
43
  "obsolete HTML tag": "過時的HTML標籤",
44
44
  "quotes": "引號",
45
- "section header in a HTML tag": "HTML標籤屬性中的段落標題",
45
+ "section header in an HTML tag": "HTML標籤屬性中的段落標題",
46
46
  "table": "表格",
47
47
  "tag that is both closing and self-closing": "同時閉合和自封閉的標籤",
48
48
  "template in an internal link target": "內部連結目標包含模板",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikiparser-node",
3
- "version": "1.16.3",
3
+ "version": "1.16.5",
4
4
  "description": "A Node.js parser for MediaWiki markup with AST",
5
5
  "keywords": [
6
6
  "mediawiki",
@@ -20,7 +20,7 @@
20
20
  "/extensions/*.css",
21
21
  "!/extensions/dist/gh-page.js",
22
22
  "!/extensions/gh-page.css",
23
- "!/extensions/dist/parserTests.js",
23
+ "!/extensions/dist/test-page.js",
24
24
  "!/extensions/test-page.css",
25
25
  "!/extensions/dist/compare.js",
26
26
  "!/extensions/compare.css",
@@ -71,7 +71,7 @@
71
71
  ]
72
72
  },
73
73
  "dependencies": {
74
- "@bhsd/common": "^0.6.4",
74
+ "@bhsd/common": "^0.6.6",
75
75
  "@codemirror/lint": "^6.8.4",
76
76
  "chalk": "^4.1.2",
77
77
  "codejar-async": "^4.2.6",
@@ -1,89 +0,0 @@
1
- (() => {
2
- "use strict";
3
- (async () => {
4
- const tests = await (await fetch('./test/parserTests.json')).json(), key = 'wikiparser-node-done', dones = new Set(JSON.parse(localStorage.getItem(key))), isGH = location.hostname.endsWith('.github.io'), isIframe = self !== top, select = document.querySelector('select'), btn = document.querySelector('button'), pre = document.querySelector('pre'), container = document.getElementById('frame'), container1 = document.getElementById('frame1'), container2 = document.getElementById('frame2');
5
- Parser.config = await (await fetch('./config/default.json')).json();
6
- wikiparse.print = (wikitext, include, stage) => {
7
- const printed = Parser.parse(wikitext, include, stage).print();
8
- return Promise.resolve([[stage !== null && stage !== void 0 ? stage : Infinity, wikitext, printed]]);
9
- };
10
- wikiparse.highlight(pre, false, true);
11
- btn.disabled = !select.value;
12
- if (!isGH) {
13
- btn.style.display = '';
14
- }
15
- let optgroup;
16
- for (const [i, { desc, wikitext, html }] of tests.entries()) {
17
- if (wikitext === undefined) {
18
- optgroup = document.createElement('optgroup');
19
- optgroup.label = desc;
20
- select.append(optgroup);
21
- }
22
- else if ((isIframe || html !== undefined) && (isGH || !dones.has(desc))) {
23
- const option = document.createElement('option');
24
- option.value = String(i);
25
- option.textContent = desc;
26
- optgroup.append(option);
27
- }
28
- }
29
- select.addEventListener('change', () => {
30
- const { wikitext, html, render, desc } = tests[Number(select.value)];
31
- pre.textContent = wikitext;
32
- pre.classList.remove('wikiparser');
33
- container.removeAttribute('data-source');
34
- if (html === undefined) {
35
- container.style.display = 'none';
36
- }
37
- else {
38
- container.style.display = '';
39
- container1.innerHTML = html;
40
- container2.innerHTML = render !== null && render !== void 0 ? render : '';
41
- }
42
- wikiparse.highlight(pre, false, true);
43
- select.selectedOptions[0].disabled = true;
44
- btn.disabled = false;
45
- history.replaceState(null, '', `#${encodeURIComponent(desc)}`);
46
- dispatchEvent(new Event('casechange'));
47
- });
48
- btn.addEventListener('click', () => {
49
- dones.add(tests[Number(select.value)].desc);
50
- localStorage.setItem(key, JSON.stringify([...dones]));
51
- while (select.selectedOptions[0].disabled) {
52
- select.selectedIndex++;
53
- }
54
- select.dispatchEvent(new Event('change'));
55
- });
56
- container.addEventListener('click', e => {
57
- e.preventDefault();
58
- }, { capture: true });
59
- container.addEventListener('dblclick', e => {
60
- e.preventDefault();
61
- if (container.dataset['source']) {
62
- container.removeAttribute('data-source');
63
- container1.innerHTML = container1.textContent;
64
- container2.innerHTML = container2.textContent;
65
- }
66
- else {
67
- container.dataset['source'] = '1';
68
- const pre1 = document.createElement('pre'), pre2 = document.createElement('pre'), code1 = document.createElement('code'), code2 = document.createElement('code');
69
- code1.textContent = container1.innerHTML;
70
- code2.textContent = container2.innerHTML;
71
- pre1.className = 'language-html';
72
- pre2.className = 'language-html';
73
- pre1.append(code1);
74
- pre2.append(code2);
75
- container1.replaceChildren(pre1);
76
- container2.replaceChildren(pre2);
77
- Prism.highlightAllUnder(container);
78
- }
79
- });
80
- addEventListener('hashchange', () => {
81
- const hash = decodeURIComponent(location.hash.slice(1)), i = tests.findIndex(({ desc }) => desc === hash);
82
- if (i !== -1) {
83
- select.value = String(i);
84
- select.dispatchEvent(new Event('change'));
85
- }
86
- });
87
- dispatchEvent(new Event('hashchange'));
88
- })();
89
- })();