wikiparser-node 0.9.2-b → 0.10.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.
- package/README.md +40 -0
- package/config/.schema.json +134 -0
- package/config/default.json +832 -0
- package/config/llwiki.json +630 -0
- package/config/moegirl.json +729 -0
- package/config/zhwiki.json +1269 -0
- package/i18n/zh-hans.json +1 -0
- package/i18n/zh-hant.json +1 -0
- package/index.js +333 -0
- package/lib/element.js +611 -0
- package/lib/node.js +770 -0
- package/lib/ranges.js +130 -0
- package/lib/text.js +263 -0
- package/lib/title.js +83 -0
- package/mixin/attributeParent.js +117 -0
- package/mixin/fixedToken.js +40 -0
- package/mixin/hidden.js +21 -0
- package/mixin/singleLine.js +31 -0
- package/mixin/sol.js +54 -0
- package/package.json +49 -47
- package/parser/brackets.js +126 -0
- package/parser/commentAndExt.js +59 -0
- package/parser/converter.js +46 -0
- package/parser/externalLinks.js +33 -0
- package/parser/hrAndDoubleUnderscore.js +49 -0
- package/parser/html.js +42 -0
- package/parser/links.js +94 -0
- package/parser/list.js +59 -0
- package/parser/magicLinks.js +41 -0
- package/parser/quotes.js +64 -0
- package/parser/selector.js +177 -0
- package/parser/table.js +114 -0
- package/src/arg.js +207 -0
- package/src/atom/hidden.js +13 -0
- package/src/atom/index.js +43 -0
- package/src/attribute.js +470 -0
- package/src/attributes.js +453 -0
- package/src/charinsert.js +97 -0
- package/src/converter.js +176 -0
- package/src/converterFlags.js +284 -0
- package/src/converterRule.js +256 -0
- package/src/extLink.js +180 -0
- package/src/gallery.js +149 -0
- package/src/hasNowiki/index.js +44 -0
- package/src/hasNowiki/pre.js +40 -0
- package/src/heading.js +134 -0
- package/src/html.js +254 -0
- package/src/imageParameter.js +303 -0
- package/src/imagemap.js +199 -0
- package/src/imagemapLink.js +41 -0
- package/src/index.js +932 -0
- package/src/link/category.js +44 -0
- package/src/link/file.js +287 -0
- package/src/link/galleryImage.js +120 -0
- package/src/link/index.js +388 -0
- package/src/magicLink.js +149 -0
- package/src/nested/choose.js +24 -0
- package/src/nested/combobox.js +23 -0
- package/src/nested/index.js +93 -0
- package/src/nested/references.js +23 -0
- package/src/nowiki/comment.js +71 -0
- package/src/nowiki/dd.js +59 -0
- package/src/nowiki/doubleUnderscore.js +56 -0
- package/src/nowiki/hr.js +41 -0
- package/src/nowiki/index.js +56 -0
- package/src/nowiki/list.js +16 -0
- package/src/nowiki/noinclude.js +28 -0
- package/src/nowiki/quote.js +69 -0
- package/src/onlyinclude.js +64 -0
- package/src/paramTag/index.js +89 -0
- package/src/paramTag/inputbox.js +35 -0
- package/src/parameter.js +239 -0
- package/src/syntax.js +91 -0
- package/src/table/index.js +983 -0
- package/src/table/td.js +338 -0
- package/src/table/tr.js +319 -0
- package/src/tagPair/ext.js +145 -0
- package/src/tagPair/include.js +50 -0
- package/src/tagPair/index.js +126 -0
- package/src/transclude.js +843 -0
- package/tool/index.js +1202 -0
- package/util/base.js +17 -0
- package/util/debug.js +73 -0
- package/util/diff.js +76 -0
- package/util/lint.js +55 -0
- package/util/string.js +126 -0
- package/bundle/bundle.min.js +0 -38
- package/extensions/editor.css +0 -62
- package/extensions/editor.js +0 -328
- package/extensions/ui.css +0 -119
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[](https://www.npmjs.com/package/wikiparser-node)
|
|
2
|
+
[](https://github.com/bhsd-harry/wikiparser-node/actions/workflows/github-code-scanning/codeql)
|
|
3
|
+
|
|
4
|
+
# 简介
|
|
5
|
+
wikiparser-node 是一款由 Bhsd 开发的基于 [Node.js](https://nodejs.org/en/) 环境的离线[维基文本](https://www.mediawiki.org/wiki/Wikitext)语法解析器,可以解析绝大部分的维基语法并生成[语法树](https://en.wikipedia.org/wiki/Abstract_syntax_tree),还可以很方便地对语法树进行查询和修改,最后返回修改后的维基文本。语法树的每个节点对应一个仿照 [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement) 类设计的类 [Token](https://github.com/bhsd-harry/wikiparser-node/wiki/01.-Token)。
|
|
6
|
+
|
|
7
|
+
# 使用方法
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
var Parser = require('wikiparser-node');
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
更多文档请查阅 [Wiki](https://github.com/bhsd-harry/wikiparser-node/wiki)。
|
|
14
|
+
|
|
15
|
+
# 目录
|
|
16
|
+
|
|
17
|
+
1. [Parser](https://github.com/bhsd-harry/wikiparser-node/wiki/Home#parser)
|
|
18
|
+
2. [AstElement](https://github.com/bhsd-harry/wikiparser-node/wiki/01.-Token#astelement)
|
|
19
|
+
3. [Token](https://github.com/bhsd-harry/wikiparser-node/wiki/01.-Token#token)
|
|
20
|
+
4. [CommentToken](https://github.com/bhsd-harry/wikiparser-node/wiki/02.-CommentToken等#commenttoken)
|
|
21
|
+
5. [ExtToken](https://github.com/bhsd-harry/wikiparser-node/wiki/03.-ExtToken)
|
|
22
|
+
6. [AttributeToken](https://github.com/bhsd-harry/wikiparser-node/wiki/04.-AttributeToken)
|
|
23
|
+
7. [HeadingToken](https://github.com/bhsd-harry/wikiparser-node/wiki/05.-HeadingToken)
|
|
24
|
+
8. [ArgToken](https://github.com/bhsd-harry/wikiparser-node/wiki/06.-ArgToken)
|
|
25
|
+
9. [TranscludeToken](https://github.com/bhsd-harry/wikiparser-node/wiki/07.-TranscludeToken)
|
|
26
|
+
10. [ParameterToken](https://github.com/bhsd-harry/wikiparser-node/wiki/08.-ParameterToken)
|
|
27
|
+
11. [HtmlToken](https://github.com/bhsd-harry/wikiparser-node/wiki/09.-HtmlToken)
|
|
28
|
+
12. [TableToken](https://github.com/bhsd-harry/wikiparser-node/wiki/10.-TableToken)
|
|
29
|
+
13. [TdToken](https://github.com/bhsd-harry/wikiparser-node/wiki/11.-TdToken)
|
|
30
|
+
14. [DoubleUnderscoreToken](https://github.com/bhsd-harry/wikiparser-node/wiki/12.-DoubleUnderscoreToken)
|
|
31
|
+
15. [LinkToken](https://github.com/bhsd-harry/wikiparser-node/wiki/13.-LinkToken)
|
|
32
|
+
16. [CategoryToken](https://github.com/bhsd-harry/wikiparser-node/wiki/14.-CategoryToken)
|
|
33
|
+
17. [FileToken](https://github.com/bhsd-harry/wikiparser-node/wiki/15.-FileToken和GalleryImageToken#filetoken)
|
|
34
|
+
18. [ImageParameterToken](https://github.com/bhsd-harry/wikiparser-node/wiki/16.-ImageParameterToken)
|
|
35
|
+
19. [ExtLinkToken](https://github.com/bhsd-harry/wikiparser-node/wiki/17.-ExtLinkToken和MagicLinkToken#extlinktoken)
|
|
36
|
+
20. [MagicLinkToken](https://github.com/bhsd-harry/wikiparser-node/wiki/17.-ExtLinkToken和MagicLinkToken#magiclinktoken)
|
|
37
|
+
21. [ConverterToken](https://github.com/bhsd-harry/wikiparser-node/wiki/18.-ConverterToken)
|
|
38
|
+
22. [ConverterRuleToken](https://github.com/bhsd-harry/wikiparser-node/wiki/19.-ConverterRuleToken)
|
|
39
|
+
23. [选择器](https://github.com/bhsd-harry/wikiparser-node/wiki/20.-选择器)
|
|
40
|
+
24. [$ (TokenCollection)](https://github.com/bhsd-harry/wikiparser-node/wiki/21.-$-(TokenCollection))
|
|
@@ -0,0 +1,134 @@
|
|
|
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
|
+
},
|
|
121
|
+
"required": [
|
|
122
|
+
"ext",
|
|
123
|
+
"html",
|
|
124
|
+
"namespaces",
|
|
125
|
+
"nsid",
|
|
126
|
+
"parserFunction",
|
|
127
|
+
"doubleUnderscore",
|
|
128
|
+
"protocol",
|
|
129
|
+
"interwiki",
|
|
130
|
+
"img",
|
|
131
|
+
"variants"
|
|
132
|
+
],
|
|
133
|
+
"additionalProperties": false
|
|
134
|
+
}
|