-
Notifications
You must be signed in to change notification settings - Fork 3
Examples (internal link)
Bhsd edited this page Apr 18, 2026
·
4 revisions
展开
你可以在页面中设置分类的排序关键字。此示例演示了 CategoryToken 的用法。
// Setting the sort key of a category (main)
// 包含 `Category:Foo` 的页面内容
import type {CategoryToken} from "wikiparser-node";
const content = `Foo
[[Category:Foo]]`,
root = Parser.parse(content),
category = root.querySelector<CategoryToken>("category#Category:Foo");
if (category) {
category.setSortkey("*");
}
assert.equal(
root,
`Foo
[[Category:Foo|*]]`,
);展开
你可以在页面中移除图片空白的 alt 属性,以提升无障碍性。此示例演示了 ImageParameterToken 的用法。
// Removing blank alt attributes from images (main)
// 包含图片的页面内容
import type {ImageParameterToken} from "wikiparser-node";
const content = `[[File:Foo.jpg|alt=]]
<gallery>
Bar.jpg|alt=
</gallery>`,
root = Parser.parse(content),
parameters = root.querySelectorAll<ImageParameterToken>(
"image-parameter#alt",
);
for (const parameter of parameters) {
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