-
Notifications
You must be signed in to change notification settings - Fork 2
CategoryToken (EN)
bhsd edited this page Feb 22, 2024
·
12 revisions
Category.
✅ Available in the Mini and Browser versions.
Expand
type: string
Name of the category, read-only.
// name
var {firstChild} = Parser.parse('[[category:a]]');
assert.strictEqual(firstChild.name, 'Category:A');
Expand
type: string
Full link.
// link
var {firstChild} = Parser.parse('[[category:a]]');
assert.deepStrictEqual({...firstChild.link}, {
valid: true,
ns: 14,
fragment: undefined,
interwiki: '',
});
firstChild.link = 'category:b';
assert.equal(firstChild, '[[category:b]]');
Expand
type: string
Sort key.
// sortkey
var {firstChild} = Parser.parse('[[category:a|*]]');
assert.strictEqual(firstChild.sortkey, '*');
firstChild.sortkey = 'b';
assert.equal(firstChild, '[[category:a|b]]');
✅ Expand
returns: LintError[]
Report potential grammar errors.
// lint
var {firstChild} = Parser.parse('[[category:a#]]');
assert.deepStrictEqual(firstChild.lint(), [
{
rule: 'no-ignored',
severity: 'error',
message: 'useless fragment',
startLine: 0,
startCol: 2,
startIndex: 2,
endLine: 0,
endCol: 13,
endIndex: 13,
fix: {
range: [12, 13],
text: '',
},
}
]);
Expand
returns: this
Deep clone the node.
// cloneNode
var {firstChild} = Parser.parse('[[category:a#]]');
assert.deepStrictEqual(firstChild.cloneNode(), firstChild);
Expand
param: string
category target
Set the category target.
// setTarget
var {firstChild} = Parser.parse('[[category:a]]');
firstChild.setTarget('category:b');
assert.equal(firstChild, '[[category:b]]');
Expand
param: string
sort key
Set the sort key.
// setSortkeyvar
var {firstChild} = Parser.parse('[[category:a]]');
firstChild.setSortkey('b');
assert.equal(firstChild, '[[category:a|b]]');
对维基文本批量执行语法检查的命令行工具
用于维基文本的 ESLint 插件
A command-line tool that performs linting on Wikitext in bulk
ESLint plugin for Wikitext