-
Notifications
You must be signed in to change notification settings - Fork 3
Examples (internal link) (EN)
Bhsd edited this page Apr 15, 2026
·
3 revisions
Expand
You can set the sort key of a category in the content of a page. This example demonstrates the use of CategoryToken.
// Setting the sort key of a category (main)
// The content of a page containing `Category:Foo`
var content = `Foo
[[Category:Foo]]`,
root = Parser.parse(content),
category = root.querySelector('category#Category:Foo');
if (category) {
category.setSortkey('*');
}
assert.equal(
root,
`Foo
[[Category:Foo|*]]`,
);Expand
You can removing blank alt attributes from images in the content of a page to improve accessibility. This example demonstrates the use of ImageParameterToken.
// Removing blank alt attributes from images (main)
// The content of a page containing images
var content = `[[File:Foo.jpg|alt=]]
<gallery>
Bar.jpg|alt=
</gallery>`,
root = Parser.parse(content);
for (const parameter of root.querySelectorAll('image-parameter#alt')) {
if (parameter.value === '') {
parameter.remove();
}
}
assert.equal(
root,
`[[File:Foo.jpg]]
<gallery>
Bar.jpg
</gallery>`,
);对维基文本批量执行语法检查的命令行工具
轻量级的维基模板解析器
维基文本语言服务器协议实现
用于维基文本的 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