wikiparser-node 1.41.0 → 1.43.0

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 (64) hide show
  1. package/README.md +43 -18
  2. package/bundle/bundle-es8.min.js +27 -27
  3. package/bundle/bundle-lsp.min.js +28 -28
  4. package/bundle/bundle.min.js +19 -19
  5. package/dist/addon/attribute.js +5 -7
  6. package/dist/addon/link.js +3 -2
  7. package/dist/addon/transclude.js +17 -29
  8. package/dist/bin/config.js +1 -1
  9. package/dist/extensions/typings.d.ts +1 -1
  10. package/dist/index.js +1 -2
  11. package/dist/lib/document.js +5 -5
  12. package/dist/lib/element.d.ts +3 -8
  13. package/dist/lib/element.js +2 -26
  14. package/dist/lib/lsp.d.ts +2 -0
  15. package/dist/lib/lsp.js +8 -20
  16. package/dist/lib/node.d.ts +2 -0
  17. package/dist/lib/node.js +0 -7
  18. package/dist/lib/range.d.ts +0 -7
  19. package/dist/lib/range.js +5 -14
  20. package/dist/lib/ranges.js +2 -2
  21. package/dist/lib/text.js +3 -5
  22. package/dist/map.d.ts +66 -0
  23. package/dist/map.js +2 -0
  24. package/dist/mixin/attributesParent.d.ts +4 -3
  25. package/dist/mixin/elementLike.d.ts +13 -0
  26. package/dist/mixin/elementLike.js +66 -53
  27. package/dist/parser/selector.js +3 -3
  28. package/dist/render/expand.js +4 -2
  29. package/dist/render/extension.js +139 -8
  30. package/dist/render/html.js +72 -3
  31. package/dist/render/magicWords.js +24 -131
  32. package/dist/src/arg.js +1 -2
  33. package/dist/src/atom.js +1 -1
  34. package/dist/src/attribute.d.ts +2 -2
  35. package/dist/src/attribute.js +17 -13
  36. package/dist/src/attributes.d.ts +3 -3
  37. package/dist/src/attributes.js +30 -14
  38. package/dist/src/converterRule.js +3 -5
  39. package/dist/src/extLink.js +5 -4
  40. package/dist/src/heading.js +12 -5
  41. package/dist/src/imageParameter.js +1 -2
  42. package/dist/src/index.js +4 -5
  43. package/dist/src/link/base.js +3 -5
  44. package/dist/src/link/file.js +7 -8
  45. package/dist/src/link/galleryImage.js +1 -3
  46. package/dist/src/magicLink.js +7 -7
  47. package/dist/src/multiLine/gallery.js +2 -3
  48. package/dist/src/nowiki/doubleUnderscore.d.ts +1 -0
  49. package/dist/src/nowiki/doubleUnderscore.js +4 -1
  50. package/dist/src/nowiki/quote.js +1 -3
  51. package/dist/src/onlyinclude.js +1 -2
  52. package/dist/src/parameter.js +6 -4
  53. package/dist/src/table/index.js +1 -2
  54. package/dist/src/table/td.d.ts +2 -2
  55. package/dist/src/table/td.js +5 -7
  56. package/dist/src/tag/html.js +29 -12
  57. package/dist/src/tagPair/ext.js +4 -1
  58. package/dist/src/tagPair/translate.d.ts +1 -1
  59. package/dist/src/tagPair/translate.js +1 -1
  60. package/dist/src/transclude.js +4 -2
  61. package/dist/util/debug.js +5 -7
  62. package/dist/util/html.js +3 -11
  63. package/extensions/dist/base.js +1 -1
  64. package/package.json +57 -21
package/README.md CHANGED
@@ -71,6 +71,28 @@ or
71
71
  npm i wikilint
72
72
  ```
73
73
 
74
+ #### Optional dependencies
75
+
76
+ You can install any of the following optional packages to enable advanced features:
77
+
78
+ | Package | Purpose |
79
+ | :-: | --- |
80
+ | `mathoid-texvcjs` | Diagnostics for `<math>` and `<chem>` extension tags |
81
+ | `stylelint` | Diagnostics for `style` attributes |
82
+ | `vscode-css-languageservice` | CSS language support for `style` attributes |
83
+ | `vscode-html-languageservice` | Language support for HTML tags |
84
+ | `vscode-json-languageservice` | JSON language support for `<templatedata>`, `<mapframe>`, `<maplink>` tags |
85
+ | `mediawiki-expr` | Evaluation of parser functions `#expr` and `#ifexpr` |
86
+ | `prismjs` + `prism-wiki` | Syntax highlighting of `<syntaxhighlight>` extension tags |
87
+
88
+ ```sh
89
+ # Full LanguageService features for `Parser.createLanguageService()`
90
+ npm i mathoid-texvcjs stylelint vscode-css-languageservice vscode-html-languageservice vscode-json-languageservice
91
+
92
+ # Full HTML conversion support for `Parser.toHtml()`
93
+ npm i mediawiki-expr prismjs prism-wiki
94
+ ```
95
+
74
96
  ### Browser
75
97
 
76
98
  You can download the code via CDN, for example:
@@ -115,6 +137,7 @@ Please refer to the [Wiki](https://github.com/bhsd-harry/wikiparser-node/wiki/Ho
115
137
  ```ts
116
138
  import Parser from "wikiparser-node";
117
139
  import type {TranscludeToken} from "wikiparser-node";
140
+
118
141
  Parser.config = "enwiki";
119
142
  const root = Parser.parse("{{Infobox|name=Old}}\nText"),
120
143
  template = root.querySelector<TranscludeToken>("template#Template:Infobox");
@@ -141,7 +164,7 @@ The following limitations are documented for transparency.
141
164
  ### Parser
142
165
 
143
166
  1. Memory leaks may occur in rare cases.
144
- 1. Invalid page names with unicode characters are treated like valid ones ([Example](http://bhsd-harry.github.io/wikiparser-node/tests.html#Render%20invalid%20page%20names%20as%20plain%20text%20(T53090))).
167
+ 1. Invalid page names with unicode characters are treated like valid ones ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#Render%20invalid%20page%20names%20as%20plain%20text%20(T53090))).
145
168
  1. Preformatted text with a leading space is only processed by [`Token#toHtml`](https://github.com/bhsd-harry/wikiparser-node/wiki/Token-%28EN%29#tohtml).
146
169
  1. BCP 47 language codes are not supported in language conversion ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#Explicit%20definition%20of%20language%20variant%20alternatives%20(BCP%2047%20codes))).
147
170
 
@@ -152,53 +175,55 @@ The following limitations are documented for transparency.
152
175
 
153
176
  #### Extension
154
177
 
155
- 1. Many extensions are not supported, such as `<indicator>` and `<ref>`.
156
- 1. `&` needs to be escaped in `<syntaxhighlight>` ([Example](http://bhsd-harry.github.io/wikiparser-node/tests.html#XSS%20is%20escaped)).
178
+ 1. Many [extensions](https://github.com/bhsd-harry/wikiparser-node/wiki/Extensions-%28EN%29#support) are not supported.
179
+ 1. [Sub-referencing](https://meta.wikimedia.org/wiki/WMDE_Technical_Wishes/Sub-referencing) is not supported.
157
180
 
158
181
  #### Transclusion
159
182
 
160
- 1. Some parser functions are not supported.
161
- 1. New lines in `{{localurl:}}` are not handled correctly ([Example](http://bhsd-harry.github.io/wikiparser-node/tests.html#Basic%20%7B%7Blocalurle%3A%7D%7D%20test)).
183
+ 1. Some parser functions are not supported, notably [`#formatdate`](https://bhsd-harry.github.io/wikiparser-node/tests.html#formatdate%20parser%20function), [`#time`](https://bhsd-harry.github.io/wikiparser-node/tests.html#Input%20times%20are%20UTC%2C%20not%20local%20time) and [`#invoke`](https://bhsd-harry.github.io/wikiparser-node/tests.html#Scribunto%3A%20hello%20world).
184
+ 1. New lines in `{{localurl:}}` are not handled correctly ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#Basic%20%7B%7Blocalurle%3A%7D%7D%20test)).
162
185
 
163
186
  #### Heading
164
187
 
165
- 1. The table of contents (TOC) is not supported.
188
+ 1. RTL support in the table of contents (TOC) ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#span%20tags%20with%20directionality%20in%20TOC)).
166
189
 
167
190
  #### HTML tag
168
191
 
169
- 1. Style sanitization is sometimes different ([Example](http://bhsd-harry.github.io/wikiparser-node/tests.html#CSS%20safety%20test%20(all%20browsers)%3A%20vertical%20tab%20(T57332%20%2F%20CVE-2013-4567))).
170
- 1. Table fostered content from `<table>` HTML tags ([Example](http://bhsd-harry.github.io/wikiparser-node/tests.html#6.%20Encapsulate%20foster-parented%20transclusion%20content)).
192
+ 1. Style sanitization is sometimes different ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#CSS%20safety%20test%20(all%20browsers)%3A%20vertical%20tab%20(T57332%20%2F%20CVE-2013-4567))).
193
+ 1. Table fostered content from `<table>` HTML tags ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#6.%20Encapsulate%20foster-parented%20transclusion%20content)).
171
194
 
172
195
  #### Table
173
196
 
174
- 1. `<caption>` elements are wrapped in `<tbody>` elements ([Example](http://bhsd-harry.github.io/wikiparser-node/tests.html#Trim%20whitespace%20in%20wikitext%20headings%2C%20list%20items%2C%20table%20captions%2C%20headings%2C%20and%20cells)).
175
- 1. Unclosed HTML tags in the table fostered content ([Example](http://bhsd-harry.github.io/wikiparser-node/tests.html#Fuzz%20testing%3A%20Parser24)).
176
- 1. `<tr>` elements should not be fostered ([Example](http://bhsd-harry.github.io/wikiparser-node/tests.html#Empty%20TR%20followed%20by%20a%20template-generated%20TR)).
197
+ 1. `<caption>` elements are wrapped in `<tbody>` elements ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#Trim%20whitespace%20in%20wikitext%20headings%2C%20list%20items%2C%20table%20captions%2C%20headings%2C%20and%20cells)).
198
+ 1. Unclosed HTML tags in the table fostered content ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#Fuzz%20testing%3A%20Parser24)).
199
+ 1. `<tr>` elements should not be fostered ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#Empty%20TR%20followed%20by%20a%20template-generated%20TR)).
200
+ 1. Link text containing `!!` in a table header ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#Exclamation%20points%20in%20wikilink%20content%20in%20table%20precedence)).
177
201
 
178
202
  #### Link
179
203
 
180
204
  1. Link trail is not supported ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#1.%20Interaction%20of%20linktrail%20and%20template%20encapsulation)).
181
- 1. Block elements inside a link should break it into multiple links ([Example](http://bhsd-harry.github.io/wikiparser-node/tests.html#%3Cpre%3E%20inside%20a%20link)).
205
+ 1. Block elements inside a link should break it into multiple links ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#%3Cpre%3E%20inside%20a%20link)).
182
206
  1. Invalid or missing images (Examples [1](https://bhsd-harry.github.io/wikiparser-node/tests.html#Fuzz%20testing%3A%20image%20with%20bogus%20manual%20thumbnail), [2](https://bhsd-harry.github.io/wikiparser-node/tests.html#Gallery%20with%20line%20not%20in%20the%20file%20namespace)).
183
- 1. Link starting with `../` on a subpage ([Example](http://bhsd-harry.github.io/wikiparser-node/tests.html#Parent%20directory%20in%20redirect)).
207
+ 1. Link starting with `../` on a subpage ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#Parent%20directory%20in%20redirect)).
184
208
 
185
209
  #### External link
186
210
 
187
- 1. External images are not supported (Examples [1](http://bhsd-harry.github.io/wikiparser-node/tests.html#External%20image), [2](http://bhsd-harry.github.io/wikiparser-node/tests.html#External%20links%3A%20Clickable%20images)).
188
- 1. No percent-encoding in displayed free external links ([Example](http://bhsd-harry.github.io/wikiparser-node/tests.html#Parsoid%3A%20pipe%20in%20transclusion%20parameter)).
211
+ 1. External images are not supported (Examples [1](https://bhsd-harry.github.io/wikiparser-node/tests.html#External%20image), [2](https://bhsd-harry.github.io/wikiparser-node/tests.html#External%20links%3A%20Clickable%20images)).
212
+ 1. No percent-encoding in displayed free external links ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#Parsoid%3A%20pipe%20in%20transclusion%20parameter)).
189
213
 
190
214
  #### Block element
191
215
 
192
- 1. Incomplete `<p>` wrapping when there are block elements (e.g., [`<pre>`](http://bhsd-harry.github.io/wikiparser-node/tests.html#%3Cpre%3E%20inside%20a%20link), [`<div>`](http://bhsd-harry.github.io/wikiparser-node/tests.html#Templates%3A%20Scopes%20should%20not%20be%20expanded%20unnecessarily) or even [closing tags](http://bhsd-harry.github.io/wikiparser-node/tests.html#Non-word%20characters%20don't%20terminate%20tag%20names%20(T19663%2C%20T42670%2C%20T54022))).
193
- 1. Mixed lists ([Example](http://bhsd-harry.github.io/wikiparser-node/tests.html#Mixed%20Lists%3A%20Test%204)).
216
+ 1. Incomplete `<p>` wrapping when there are block elements (e.g., [`<pre>`](https://bhsd-harry.github.io/wikiparser-node/tests.html#%3Cpre%3E%20inside%20a%20link), [`<div>`](https://bhsd-harry.github.io/wikiparser-node/tests.html#Templates%3A%20Scopes%20should%20not%20be%20expanded%20unnecessarily) or even [closing tags](https://bhsd-harry.github.io/wikiparser-node/tests.html#Non-word%20characters%20don't%20terminate%20tag%20names%20(T19663%2C%20T42670%2C%20T54022))).
217
+ 1. Mixed lists ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#Mixed%20Lists%3A%20Test%204)).
194
218
 
195
219
  #### Language conversion
196
220
 
197
221
  1. Automatic language conversion is not supported.
198
222
  1. Support for manual language conversion is minimal ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#Explicit%20session-wise%20one-way%20language%20variant%20mapping%20(A%20flag%20and%20-%20flag))).
223
+ 1. BCP 47 language codes are not supported in language conversion ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#Explicit%20definition%20of%20language%20variant%20alternatives%20(BCP%2047%20codes))).
199
224
 
200
225
  #### Miscellaneous
201
226
 
202
- 1. Illegal HTML entities ([Example](http://bhsd-harry.github.io/wikiparser-node/tests.html#Illegal%20character%20references%20(T106578%2C%20T113194))).
227
+ 1. Illegal HTML entities ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#Illegal%20character%20references%20(T106578%2C%20T113194))).
203
228
 
204
229
  </details>