wikiparser-node 1.0.2-b → 1.0.3

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 (157) hide show
  1. package/README.en.md +57 -0
  2. package/README.md +5 -1
  3. package/config/.schema.json +160 -0
  4. package/config/llwiki.json +35 -1
  5. package/config/moegirl.json +44 -1
  6. package/config/zhwiki.json +466 -1
  7. package/dist/addon/table.d.ts +6 -0
  8. package/dist/addon/table.js +531 -0
  9. package/dist/bin/toc.js +18 -0
  10. package/dist/index.d.ts +60 -0
  11. package/dist/index.js +205 -0
  12. package/dist/internal.d.ts +44 -0
  13. package/dist/lib/element.d.ts +155 -0
  14. package/dist/lib/element.js +655 -0
  15. package/dist/lib/node.d.ts +143 -0
  16. package/dist/lib/node.js +419 -0
  17. package/dist/lib/range.d.ts +115 -0
  18. package/dist/lib/range.js +353 -0
  19. package/dist/lib/ranges.d.ts +28 -0
  20. package/dist/lib/ranges.js +120 -0
  21. package/dist/lib/text.d.ts +63 -0
  22. package/dist/lib/text.js +217 -0
  23. package/dist/lib/title.d.ts +26 -0
  24. package/dist/lib/title.js +125 -0
  25. package/dist/mixin/attributesParent.js +94 -0
  26. package/dist/mixin/fixed.js +32 -0
  27. package/dist/mixin/flagsParent.js +70 -0
  28. package/dist/mixin/hidden.js +22 -0
  29. package/dist/mixin/magicLinkParent.js +41 -0
  30. package/dist/mixin/singleLine.js +25 -0
  31. package/dist/mixin/sol.js +43 -0
  32. package/dist/mixin/syntax.js +56 -0
  33. package/dist/parser/braces.js +123 -0
  34. package/dist/parser/commentAndExt.js +65 -0
  35. package/dist/parser/converter.js +40 -0
  36. package/dist/parser/externalLinks.js +28 -0
  37. package/dist/parser/hrAndDoubleUnderscore.js +38 -0
  38. package/dist/parser/html.js +36 -0
  39. package/dist/parser/links.js +94 -0
  40. package/dist/parser/list.js +59 -0
  41. package/dist/parser/magicLinks.js +40 -0
  42. package/dist/parser/quotes.js +67 -0
  43. package/dist/parser/selector.js +163 -0
  44. package/dist/parser/table.js +110 -0
  45. package/dist/src/arg.d.ts +58 -0
  46. package/dist/src/arg.js +190 -0
  47. package/dist/src/atom.d.ts +12 -0
  48. package/dist/src/atom.js +27 -0
  49. package/dist/src/attribute.d.ts +86 -0
  50. package/dist/src/attribute.js +392 -0
  51. package/dist/src/attributes.d.ts +106 -0
  52. package/dist/src/attributes.js +339 -0
  53. package/dist/src/converter.d.ts +51 -0
  54. package/dist/src/converter.js +79 -0
  55. package/dist/src/converterFlags.d.ts +87 -0
  56. package/dist/src/converterFlags.js +223 -0
  57. package/dist/src/converterRule.d.ts +81 -0
  58. package/dist/src/converterRule.js +221 -0
  59. package/dist/src/extLink.d.ts +53 -0
  60. package/dist/src/extLink.js +121 -0
  61. package/dist/src/gallery.d.ts +55 -0
  62. package/dist/src/gallery.js +129 -0
  63. package/dist/src/heading.d.ts +76 -0
  64. package/dist/src/heading.js +127 -0
  65. package/dist/src/hidden.d.ts +21 -0
  66. package/dist/src/hidden.js +23 -0
  67. package/dist/src/html.d.ts +99 -0
  68. package/dist/src/html.js +230 -0
  69. package/dist/src/imageParameter.d.ts +66 -0
  70. package/dist/src/imageParameter.js +246 -0
  71. package/dist/src/imagemap.d.ts +57 -0
  72. package/dist/src/imagemap.js +148 -0
  73. package/dist/src/imagemapLink.d.ts +57 -0
  74. package/dist/src/imagemapLink.js +40 -0
  75. package/dist/src/index.d.ts +145 -0
  76. package/dist/src/index.js +766 -0
  77. package/dist/src/link/base.d.ts +52 -0
  78. package/dist/src/link/base.js +198 -0
  79. package/dist/src/link/category.d.ts +13 -0
  80. package/dist/src/link/category.js +29 -0
  81. package/dist/src/link/file.d.ts +96 -0
  82. package/dist/src/link/file.js +253 -0
  83. package/dist/src/link/galleryImage.d.ts +41 -0
  84. package/dist/src/link/galleryImage.js +98 -0
  85. package/dist/src/link/index.d.ts +53 -0
  86. package/dist/src/link/index.js +123 -0
  87. package/dist/src/magicLink.d.ts +58 -0
  88. package/dist/src/magicLink.js +122 -0
  89. package/dist/src/nested.d.ts +44 -0
  90. package/dist/src/nested.js +87 -0
  91. package/dist/src/nowiki/base.d.ts +46 -0
  92. package/dist/src/nowiki/base.js +42 -0
  93. package/dist/src/nowiki/comment.d.ts +39 -0
  94. package/dist/src/nowiki/comment.js +67 -0
  95. package/dist/src/nowiki/dd.d.ts +8 -0
  96. package/dist/src/nowiki/dd.js +25 -0
  97. package/dist/src/nowiki/doubleUnderscore.d.ts +43 -0
  98. package/dist/src/nowiki/doubleUnderscore.js +51 -0
  99. package/dist/src/nowiki/hr.d.ts +29 -0
  100. package/dist/src/nowiki/hr.js +14 -0
  101. package/dist/src/nowiki/index.d.ts +16 -0
  102. package/dist/src/nowiki/index.js +21 -0
  103. package/dist/src/nowiki/list.d.ts +29 -0
  104. package/dist/src/nowiki/list.js +47 -0
  105. package/dist/src/nowiki/listBase.d.ts +18 -0
  106. package/dist/src/nowiki/listBase.js +12 -0
  107. package/dist/src/nowiki/noinclude.d.ts +25 -0
  108. package/dist/src/nowiki/noinclude.js +25 -0
  109. package/dist/src/nowiki/quote.d.ts +22 -0
  110. package/dist/src/nowiki/quote.js +50 -0
  111. package/dist/src/onlyinclude.d.ts +16 -0
  112. package/dist/src/onlyinclude.js +57 -0
  113. package/dist/src/paramTag/index.d.ts +37 -0
  114. package/dist/src/paramTag/index.js +68 -0
  115. package/dist/src/paramTag/inputbox.d.ts +8 -0
  116. package/dist/src/paramTag/inputbox.js +23 -0
  117. package/dist/src/parameter.d.ts +82 -0
  118. package/dist/src/parameter.js +202 -0
  119. package/dist/src/pre.d.ts +28 -0
  120. package/dist/src/pre.js +51 -0
  121. package/dist/src/syntax.d.ts +25 -0
  122. package/dist/src/syntax.js +30 -0
  123. package/dist/src/table/base.d.ts +52 -0
  124. package/dist/src/table/base.js +78 -0
  125. package/dist/src/table/index.d.ts +229 -0
  126. package/dist/src/table/index.js +364 -0
  127. package/dist/src/table/td.d.ts +102 -0
  128. package/dist/src/table/td.js +261 -0
  129. package/dist/src/table/tr.d.ts +32 -0
  130. package/dist/src/table/tr.js +56 -0
  131. package/dist/src/table/trBase.d.ts +54 -0
  132. package/dist/src/table/trBase.js +151 -0
  133. package/dist/src/tagPair/ext.d.ts +55 -0
  134. package/dist/src/tagPair/ext.js +142 -0
  135. package/dist/src/tagPair/include.d.ts +52 -0
  136. package/dist/src/tagPair/include.js +58 -0
  137. package/dist/src/tagPair/index.d.ts +47 -0
  138. package/dist/src/tagPair/index.js +93 -0
  139. package/dist/src/transclude.d.ts +167 -0
  140. package/dist/src/transclude.js +694 -0
  141. package/dist/util/constants.js +108 -0
  142. package/dist/util/debug.js +63 -0
  143. package/dist/util/diff.js +72 -0
  144. package/dist/util/lint.js +48 -0
  145. package/dist/util/string.js +63 -0
  146. package/errors/README +1 -0
  147. package/i18n/zh-hans.json +2 -0
  148. package/i18n/zh-hant.json +2 -0
  149. package/package.json +12 -24
  150. package/printed/README +1 -0
  151. package/bundle/bundle.min.js +0 -37
  152. package/extensions/dist/base.js +0 -70
  153. package/extensions/dist/editor.js +0 -172
  154. package/extensions/dist/highlight.js +0 -39
  155. package/extensions/dist/lint.js +0 -48
  156. package/extensions/editor.css +0 -63
  157. package/extensions/ui.css +0 -119
package/README.en.md ADDED
@@ -0,0 +1,57 @@
1
+ [![npm version](https://badge.fury.io/js/wikiparser-node.svg)](https://www.npmjs.com/package/wikiparser-node)
2
+ [![CodeQL](https://github.com/bhsd-harry/wikiparser-node/actions/workflows/codeql.yml/badge.svg)](https://github.com/bhsd-harry/wikiparser-node/actions/workflows/codeql.yml)
3
+ [![CI](https://github.com/bhsd-harry/wikiparser-node/actions/workflows/node.js.yml/badge.svg)](https://github.com/bhsd-harry/wikiparser-node/actions/workflows/node.js.yml)
4
+
5
+ # Other Languages
6
+
7
+ - [简体中文](./README.md)
8
+
9
+ # Introduction
10
+
11
+ wikiparser-node is an offline [Wikitext](https://www.mediawiki.org/wiki/Wikitext) parser developed by Bhsd for the [Node.js](https://nodejs.org/) environment. It can parse almost all wiki syntax and generate an [Abstract Syntax Tree (AST)](https://en.wikipedia.org/wiki/Abstract_syntax_tree). It also allows for easy querying and modification of the AST, and returns the modified wikitext.
12
+
13
+ # Other Versions
14
+
15
+ ## Mini (also known as [wikilint](https://www.npmjs.com/package/wikilint))
16
+
17
+ This version provides a [CLI](https://en.wikipedia.org/wiki/Command-line_interface), but only retains the parsing functionality and linting functionality. The parsed AST cannot be modified. It is used in the [eslint-plugin-wikitext](https://www.npmjs.com/package/eslint-plugin-wikitext) plugin.
18
+
19
+ ## Browser
20
+
21
+ A browser-compatible version, which can be used for code highlighting or as a linting plugin in conjunction with the [CodeMirror5](https://codemirror.net/5/) editor. ([Usage example](https://bhsd-harry.github.io/wikiparser-node))
22
+
23
+ # Installation
24
+
25
+ ## Node.js
26
+
27
+ Please install the corresponding version as needed (`wikiparser-node` or `wikilint`), for example:
28
+
29
+ ```sh
30
+ npm i wikiparser-node
31
+ ```
32
+
33
+ or
34
+
35
+ ```sh
36
+ npm i wikilint
37
+ ```
38
+
39
+ ## Browser
40
+
41
+ You can download the code via CDN, for example:
42
+
43
+ ```html
44
+ <script src="//cdn.jsdelivr.net/npm/wikiparser-node@browser/bundle/bundle.min.js"></script>
45
+ ```
46
+
47
+ or
48
+
49
+ ```html
50
+ <script src="//unpkg.com/wikiparser-node@browser/bundle/bundle.min.js"></script>
51
+ ```
52
+
53
+ For more browser extensions, please refer to the corresponding [documentation](https://github.com/bhsd-harry/wikiparser-node/wiki/Browser.en).
54
+
55
+ # Usage
56
+
57
+ Please refer to the [Wiki](https://github.com/bhsd-harry/wikiparser-node/wiki/Home.en).
package/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
  [![CodeQL](https://github.com/bhsd-harry/wikiparser-node/actions/workflows/codeql.yml/badge.svg)](https://github.com/bhsd-harry/wikiparser-node/actions/workflows/codeql.yml)
3
3
  [![CI](https://github.com/bhsd-harry/wikiparser-node/actions/workflows/node.js.yml/badge.svg)](https://github.com/bhsd-harry/wikiparser-node/actions/workflows/node.js.yml)
4
4
 
5
+ # Other Languages
6
+
7
+ - [English](./README.en.md)
8
+
5
9
  # 简介
6
10
 
7
11
  wikiparser-node 是一款由 Bhsd 开发的基于 [Node.js](https://nodejs.org/) 环境的离线[维基文本](https://www.mediawiki.org/wiki/Wikitext)语法解析器,可以解析几乎全部的维基语法并生成[语法树](https://en.wikipedia.org/wiki/Abstract_syntax_tree),还可以很方便地对语法树进行查询和修改,最后返回修改后的维基文本。
@@ -46,7 +50,7 @@ npm i wikilint
46
50
  <script src="//unpkg.com/wikiparser-node@browser/bundle/bundle.min.js"></script>
47
51
  ```
48
52
 
49
- 更多浏览器端可用的插件请查阅对应文档。
53
+ 更多浏览器端可用的插件请查阅对应[文档](https://github.com/bhsd-harry/wikiparser-node/wiki/Browser)。
50
54
 
51
55
  # 使用方法
52
56
 
@@ -0,0 +1,160 @@
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
+ }
@@ -518,7 +518,41 @@
518
518
  ]
519
519
  ],
520
520
  "protocol": "bitcoin:|ftp://|ftps://|geo:|git://|gopher://|http://|https://|irc://|ircs://|magnet:|mailto:|mms://|news:|nntp://|redis://|sftp://|sip:|sips:|sms:|ssh://|svn://|tel:|telnet://|urn:|worldwind://|xmpp:",
521
- "interwiki": [],
521
+ "interwiki": [
522
+ "arxiv",
523
+ "aswiki",
524
+ "cache",
525
+ "cmoegirl",
526
+ "commons",
527
+ "doi",
528
+ "google",
529
+ "googlegroups",
530
+ "gsnews",
531
+ "imdb",
532
+ "jawiki",
533
+ "komica",
534
+ "mediawikiwiki",
535
+ "metawikimedia",
536
+ "moegirl",
537
+ "mw",
538
+ "sifaswiki",
539
+ "sifwiki",
540
+ "wikia",
541
+ "wikibooks",
542
+ "wikidata",
543
+ "wikimedia",
544
+ "wikinews",
545
+ "wikiinfo",
546
+ "wikipedia",
547
+ "wikiquote",
548
+ "wikisource",
549
+ "wikispecies",
550
+ "wikiversity",
551
+ "wikivoyage",
552
+ "wikt",
553
+ "wiktionary",
554
+ "zhwiki"
555
+ ],
522
556
  "img": {
523
557
  "thumbnail": "thumbnail",
524
558
  "thumb": "thumbnail",
@@ -611,7 +611,50 @@
611
611
  ]
612
612
  ],
613
613
  "protocol": "bitcoin:|ftp://|ftps://|geo:|git://|gopher://|http://|https://|irc://|ircs://|magnet:|mailto:|mms://|news:|nntp://|redis://|sftp://|sip:|sips:|sms:|ssh://|svn://|tel:|telnet://|urn:|worldwind://|xmpp:",
614
- "interwiki": [],
614
+ "interwiki": [
615
+ "commons",
616
+ "mediawikiwiki",
617
+ "metawikimedia",
618
+ "mw",
619
+ "wikibooks",
620
+ "wikidata",
621
+ "wikimedia",
622
+ "wikinews",
623
+ "wikipedia",
624
+ "wikiquote",
625
+ "wikisource",
626
+ "wikispecies",
627
+ "wikiversity",
628
+ "wikivoyage",
629
+ "wikt",
630
+ "wiktionary",
631
+ "cc",
632
+ "cm",
633
+ "en",
634
+ "enmoe",
635
+ "enwp",
636
+ "fandom",
637
+ "ghia",
638
+ "huiji",
639
+ "ja",
640
+ "jamoe",
641
+ "jawp",
642
+ "library",
643
+ "meta",
644
+ "phab",
645
+ "pmid",
646
+ "shoutwiki",
647
+ "translatewiki",
648
+ "zh",
649
+ "zhmoe",
650
+ "zhmoegirl",
651
+ "zhtest",
652
+ "zhwp",
653
+ "文库",
654
+ "萌娘共享",
655
+ "萌娘文库",
656
+ "萌百"
657
+ ],
615
658
  "img": {
616
659
  "thumbnail": "thumbnail",
617
660
  "thumb": "thumbnail",