wikiparser-node 1.42.0 → 1.44.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 (60) hide show
  1. package/README.md +45 -19
  2. package/bundle/bundle-es8.min.js +40 -31
  3. package/bundle/bundle-lsp.min.js +35 -26
  4. package/bundle/bundle.min.js +22 -22
  5. package/config/default.json +31 -0
  6. package/config/moegirl.json +39 -1
  7. package/dist/addon/attribute.js +4 -6
  8. package/dist/addon/link.js +3 -2
  9. package/dist/addon/transclude.js +16 -26
  10. package/dist/base.d.mts +4 -4
  11. package/dist/base.d.ts +4 -4
  12. package/dist/base.js +1 -0
  13. package/dist/base.mjs +1 -0
  14. package/dist/bin/config.js +6 -5
  15. package/dist/extensions/typings.d.ts +1 -1
  16. package/dist/index.js +8 -5
  17. package/dist/lib/document.d.ts +17 -14
  18. package/dist/lib/document.js +5 -5
  19. package/dist/lib/lintConfig.js +4 -1
  20. package/dist/lib/ranges.js +2 -2
  21. package/dist/lib/title.d.ts +4 -1
  22. package/dist/lib/title.js +5 -1
  23. package/dist/mixin/attributesParent.js +1 -1
  24. package/dist/parser/converter.js +1 -1
  25. package/dist/render/expand.js +4 -2
  26. package/dist/render/extension.js +30 -24
  27. package/dist/render/magicWords.js +25 -132
  28. package/dist/render/math.js +31 -0
  29. package/dist/render/syntaxhighlight.js +3 -0
  30. package/dist/src/arg.js +1 -2
  31. package/dist/src/atom.js +1 -1
  32. package/dist/src/attributes.d.ts +1 -0
  33. package/dist/src/attributes.js +27 -3
  34. package/dist/src/converterFlags.js +10 -5
  35. package/dist/src/converterRule.js +5 -7
  36. package/dist/src/heading.js +1 -2
  37. package/dist/src/imageParameter.d.ts +4 -3
  38. package/dist/src/imageParameter.js +16 -9
  39. package/dist/src/index.js +1 -1
  40. package/dist/src/link/base.js +1 -1
  41. package/dist/src/link/file.d.ts +5 -4
  42. package/dist/src/link/file.js +14 -12
  43. package/dist/src/magicLink.js +1 -2
  44. package/dist/src/nowiki/index.d.ts +1 -0
  45. package/dist/src/nowiki/index.js +40 -28
  46. package/dist/src/onlyinclude.js +1 -2
  47. package/dist/src/parameter.js +1 -2
  48. package/dist/src/table/index.js +1 -2
  49. package/dist/src/table/td.js +4 -6
  50. package/dist/src/tagPair/ext.d.ts +1 -0
  51. package/dist/src/tagPair/ext.js +36 -3
  52. package/dist/src/transclude.js +5 -3
  53. package/dist/util/search.js +24 -6
  54. package/dist/util/string.js +7 -1
  55. package/extensions/dist/base.js +1 -1
  56. package/extensions/dist/codejar.js +1 -1
  57. package/i18n/en.json +7 -0
  58. package/i18n/zh-hans.json +7 -0
  59. package/i18n/zh-hant.json +7 -0
  60. package/package.json +64 -21
package/README.md CHANGED
@@ -71,6 +71,29 @@ 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 and HTML conversion support 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>` and `<maplink>` tags |
85
+ | `katex` | HTML conversion support for `<math>` and `<chem>` extension tags |
86
+ | `mediawiki-expr` | Evaluation of parser functions `#expr` and `#ifexpr` |
87
+ | `prismjs` + `prism-wiki` | Syntax highlighting of `<syntaxhighlight>` extension tags |
88
+
89
+ ```sh
90
+ # Full LanguageService features for `Parser.createLanguageService()`
91
+ npm i mathoid-texvcjs stylelint vscode-css-languageservice vscode-html-languageservice vscode-json-languageservice
92
+
93
+ # Full HTML conversion support for `Parser.toHtml()`
94
+ npm i katex mathoid-texvcjs mediawiki-expr prismjs prism-wiki
95
+ ```
96
+
74
97
  ### Browser
75
98
 
76
99
  You can download the code via CDN, for example:
@@ -142,9 +165,8 @@ The following limitations are documented for transparency.
142
165
  ### Parser
143
166
 
144
167
  1. Memory leaks may occur in rare cases.
145
- 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))).
168
+ 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))).
146
169
  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).
147
- 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))).
148
170
 
149
171
  ### HTML conversion
150
172
 
@@ -153,54 +175,58 @@ The following limitations are documented for transparency.
153
175
 
154
176
  #### Extension
155
177
 
156
- 1. Many extensions are not supported.
178
+ 1. Many [extensions](https://github.com/bhsd-harry/wikiparser-node/wiki/Extensions-%28EN%29#support) are not supported.
157
179
  1. [Sub-referencing](https://meta.wikimedia.org/wiki/WMDE_Technical_Wishes/Sub-referencing) is not supported.
180
+ 1. Special cases involving templates inside the `link` parameter of a gallery image ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#Link%20media%20option%20with%20template%20with%20arguments)).
158
181
 
159
182
  #### Transclusion
160
183
 
161
- 1. Some parser functions are not supported.
162
- 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)).
184
+ 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).
185
+ 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)).
163
186
 
164
187
  #### Heading
165
188
 
166
- 1. RTL support in the table of contents (TOC) ([Example](http://bhsd-harry.github.io/wikiparser-node/tests.html#span%20tags%20with%20directionality%20in%20TOC)).
189
+ 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)).
167
190
 
168
191
  #### HTML tag
169
192
 
170
- 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))).
171
- 1. Table fostered content from `<table>` HTML tags ([Example](http://bhsd-harry.github.io/wikiparser-node/tests.html#6.%20Encapsulate%20foster-parented%20transclusion%20content)).
193
+ 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))).
172
194
 
173
195
  #### Table
174
196
 
175
- 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)).
176
- 1. Unclosed HTML tags in the table fostered content ([Example](http://bhsd-harry.github.io/wikiparser-node/tests.html#Fuzz%20testing%3A%20Parser24)).
177
- 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)).
178
201
 
179
202
  #### Link
180
203
 
181
204
  1. Link trail is not supported ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#1.%20Interaction%20of%20linktrail%20and%20template%20encapsulation)).
182
- 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)).
183
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)).
184
- 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)).
208
+ 1. Duplicate file namespace prefixes should be invalid ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#Gallery%20with%20valid%20attributes)).
209
+ 1. File redirects ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#Gallery%20(with%20showfilename%20option))).
210
+ 1. Figure caption should not be nested inside inline elements ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#File%20in%20formatting%20element%20violating%20content%20model%2C%20figcaption%20content)).
211
+ 1. Seemingly broken file link syntax in a table ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#File%20in%20table%20pipe%20precedence)).
185
212
 
186
213
  #### External link
187
214
 
188
- 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)).
189
- 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)).
215
+ 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)).
190
216
 
191
217
  #### Block element
192
218
 
193
- 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))).
194
- 1. Mixed lists ([Example](http://bhsd-harry.github.io/wikiparser-node/tests.html#Mixed%20Lists%3A%20Test%204)).
219
+ 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))).
220
+ 1. Mixed lists ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#Mixed%20Lists%3A%20Test%204)).
195
221
 
196
222
  #### Language conversion
197
223
 
198
224
  1. Automatic language conversion is not supported.
199
225
  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))).
200
- 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))).
226
+ 1. Language conversion should prevent `<p>` wrapping (Examples [1](https://bhsd-harry.github.io/wikiparser-node/tests.html#Code%20coverage%3A%20rules%20with%20no%20variants), [2](https://bhsd-harry.github.io/wikiparser-node/tests.html#Language%20converter%20markup%20with%20block%20content)).
201
227
 
202
228
  #### Miscellaneous
203
229
 
204
- 1. Illegal HTML entities ([Example](http://bhsd-harry.github.io/wikiparser-node/tests.html#Illegal%20character%20references%20(T106578%2C%20T113194))).
230
+ 1. Illegal HTML entities ([Example](https://bhsd-harry.github.io/wikiparser-node/tests.html#Illegal%20character%20references%20(T106578%2C%20T113194))).
205
231
 
206
232
  </details>