-
Notifications
You must be signed in to change notification settings - Fork 3
Home (EN)
WikiParser-Node is an offline Wikitext parser developed by Bhsd for the Node.js environment. It can parse almost all wiki syntax and generate an Abstract Syntax Tree (AST). It also allows for easy querying and modification of the AST, and returns the modified Wikitext.
Each node of the AST corresponds to a class Token modeled after the HTMLElement class. This Wiki will introduce the properties and methods available for each type of Token corresponding to different wiki syntax.
See WikiLint. This version provides a CLI, but only retains the parsing and linting functionality. At the cost of losing AST modification capabilities, it executes 2.4x faster. It powers the Wikitext LSP, which provides multiple language services for editors such as VS Code, Sublime Text, and Helix.
A list of available linting rules can be found here.
A browser-compatible version, which can be used for code highlighting or as a LSP plugin in conjunction with editors such as CodeMirror and Monaco (Usage example). It has been integrated into the MediaWiki official CodeMirror extension since Release 1.45.
A lightweight version that only supports parsing and manipulation of templates. This version is designed for use cases where only template processing is needed, such as certain types of bots or web tools (e.g., GANReviewTool) that focus on template manipulation.
Please install the corresponding version as needed (WikiParser-Node or WikiLint), for example:
npm i wikiparser-nodeor
npm i wikilintYou can install any of the following optional packages to enable advanced features:
| Package | Purpose |
|---|---|
mathoid-texvcjs |
Diagnostics and HTML conversion support for <math> and <chem> extension tags |
stylelint |
Diagnostics for style attributes |
vscode-css-languageservice |
CSS language support for style attributes |
vscode-html-languageservice |
Language support for HTML tags |
vscode-json-languageservice |
JSON language support for <templatedata>, <mapframe> and <maplink> tags |
katex |
HTML conversion support for <math> and <chem> extension tags |
mediawiki-expr |
Evaluation of parser functions #expr and #ifexpr
|
prismjs + prism-wiki
|
Syntax highlighting of <syntaxhighlight> extension tags |
# Full LanguageService features for `Parser.createLanguageService()`
npm i mathoid-texvcjs stylelint vscode-css-languageservice vscode-html-languageservice vscode-json-languageservice
# Full HTML conversion support for `Parser.toHtml()`
npm i katex mathoid-texvcjs mediawiki-expr prismjs prism-wikiYou can download the code via CDN, for example:
<script src="//cdn.jsdelivr.net/npm/wikiparser-node"></script>or
<script src="//unpkg.com/wikiparser-node/bundle/bundle-lsp.min.js"></script>For more browser extensions, please refer to the corresponding documentation.
Please refer to the document of the main entry and the corresponding documents of each type of Token.
- Examples about redirects
- Examples about templates
- Examples about section headers
- Examples about extension/HTML tags
- Examples about tables
- Examples about internal links
- Examples about external links
- Examples about lists
A full list of linting rules can be found here.
WikiParser-Node has been extensively tested against the official MediaWiki PHP parser tests with ~3,000 test cases, covering various edge cases and peculiarities of Wikitext. These tests are available here.
对维基文本批量执行语法检查的命令行工具
轻量级的维基模板解析器
维基文本语言服务器协议实现
用于维基文本的 VS Code 扩展
A command-line tool that performs linting on Wikitext in bulk
A lightweight Wikitext template parser
An implementation of the Language Server Protocol for Wikitext
VS Code extension for Wikitext