-
Notifications
You must be signed in to change notification settings - Fork 1
wikiparse (EN)
Table of Contents
This is a global variable added by the browser extension, which can perform various operations such as highlighting static code or text boxes, reporting potential grammar errors, etc.
Expand
Requires CodeJar extension.
type: Promise<(textbox: HTMLTextAreaElement, include?: boolean, linenums?: boolean) => CodeJar>
Highlight text box.
(await wikiparse.codejar)(document.getElementsByTagName('textarea')[0]);
Expand
param: Record<string, string>
Set the language. The default language is English, and other preset languages include Simplified Chinese and Traditional Chinese.
const i18n = await (await fetch('https://bhsd-harry.github.io/wikiparser-node/i18n/zh-hans.json')).json();
wikiparse.setI18N(i18n);
Expand
param: Config
Set the parsing configuration. Preset configurations include English Wikipedia (enwiki
), Chinese Wikipedia (zhwiki
), Moegirlpedia (moegirl
) and LLWiki (llwiki
). To customize the parsing configuration of a MediaWiki site, please refer to .schema.json
for the relevant content.
const config = await (await fetch('https://bhsd-harry.github.io/wikiparser-node/config/zhwiki.json')).json();
wikiparse.setConfig(config);
Expand
returns: Promise<Config>
Get the parsing configuration.
const config = await wikiparse.getConfig();
Expand
param: string
Wikitext
param: boolean
Whether to be transcluded, default to false
returns: Promise<LintError[]>
Report potential grammar errors.
const errors = await wikiparse.lint('[[a]');
Expand
Requires Highlight extension.
param: HTMLElement
The HTML element for the static code
param: boolean
Whether to be transcluded, default to false
param: boolean
Whether to add line numbers, default to false
param: number
The starting value of line numbers, optional
returns: Promise<void>
Highlight static code.
wikiparse.highlight(document.getElementsByTagName('pre')[0], false, true);
Expand
(Deprecated) Requires Editor extension.
param: HTMLTextAreaElement
Text box
param: boolean
Whether to be transcluded, default to false
Highlight text box.
wikiparse.edit(document.getElementsByTagName('textarea')[0]);
See Linter.
对维基文本批量执行语法检查的命令行工具
用于维基文本的 ESLint 插件
A command-line tool that performs linting on Wikitext in bulk
ESLint plugin for Wikitext