wikiparse (EN) - bhsd-harry/wikiparser-node GitHub Wiki

Table of Contents

Other Languages

Introduction

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.

Properties

codejar

Expand

Requires CodeJar extension.

type: Promise<(textbox: HTMLTextAreaElement, include?: boolean, linenums?: boolean) => CodeJar>
Highlight text box.

(await wikiparse.codejar)(document.getElementsByTagName('textarea')[0]);

Methods

setI18N

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);

setConfig

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);

getConfig

Expand

returns: Promise<Config>
Get the parsing configuration.

const config = await wikiparse.getConfig();

lint

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]');

highlight

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);

edit

Expand

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]);

Constructors

Linter

See Linter.

⚠️ **GitHub.com Fallback** ⚠️