Skip to content

Home (EN)

Bhsd edited this page Jun 10, 2026 · 25 revisions

Other Languages

Introduction

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.

Used by

MediaWiki Helix LSP for Sublime Text euporie qBittorrent

Other Versions

Mini

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.

Browser-compatible

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.

Installation

Node.js

Please install the corresponding version as needed (WikiParser-Node or WikiLint), for example:

npm i wikiparser-node

or

npm i wikilint

Optional dependencies

You 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-wiki

Browser

You 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.

Usage

Please refer to the document of the main entry and the corresponding documents of each type of Token.

Examples

Rules

A full list of linting rules can be found here.

Tests

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.

Clone this wiki locally