-
Notifications
You must be signed in to change notification settings - Fork 3
Examples (tag)
Bhsd edited this page Apr 15, 2026
·
5 revisions
Expand
You can remove bolding from section headers in the content of a page. This example demonstrates the use of AstNode.prototype.remove.
// Removing bolding from section headers (main)
// The content of a page
var content = `Foo
== <b>Bar</b> ==
=== <strong>Baz</strong> ===`,
root = Parser.parse(content),
boldings = root.querySelectorAll('heading-title > html:is(#b, #strong)');
for (const html of boldings) {
html.remove();
}
assert.equal(
root,
`Foo
== Bar ==
=== Baz ===`,
);Expand
You can replace the lang attribute of <syntaxhighlight> tags from moin to wikitext in the content of a page. This example demonstrates the use of ExtToken.
// Replacing the syntaxhighlight language (main)
// The content of a page containing `<syntaxhighlight>` tags
var content = `<syntaxhighlight lang="moin">
Foo
</syntaxhighlight>`,
root = Parser.parse(content);
for (const ext of root.querySelectorAll('ext#syntaxhighlight[lang=moin]')) {
ext.setAttr('lang', 'wikitext');
}
assert.equal(
root,
`<syntaxhighlight lang="wikitext">
Foo
</syntaxhighlight>`,
);Expand
You can easily fix invalid self-closing tags in the content of a page using HtmlToken.prototype.fix.
// Replacing the syntaxhighlight language (main)
// The content of a page containing `<syntaxhighlight>` tags
var content = '<div>Foo<div/>',
root = Parser.parse(content);
for (const html of root.querySelectorAll('html[selfClosing]')) {
try {
// May throw if it cannot be automatically fixed
html.fix();
} catch {}
}
assert.equal(
root,
'<div>Foo</div>',
);对维基文本批量执行语法检查的命令行工具
轻量级的维基模板解析器
维基文本语言服务器协议实现
用于维基文本的 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