-
Notifications
You must be signed in to change notification settings - Fork 2
ExtToken
bhsd edited this page Nov 25, 2023
·
22 revisions
扩展标签。这个类同时混合了 AttributesToken 类的属性和方法。
✅ 展开
type: string
标签名。
var {firstChild} = Parser.parse('<pre>a</pre>');
assert.equal(firstChild, '<pre>a</pre>');
assert.strictEqual(firstChild.name, 'pre');
展开
type: true
不可增删子节点。
var {firstChild} = Parser.parse('<pre>a</pre>');
assert.equal(firstChild, '<pre>a</pre>');
assert(firstChild.fixed);
展开
type: boolean
是否自封闭。
var {firstChild} = Parser.parse('<ref/>');
assert.equal(firstChild, '<ref/>');
assert(firstChild.selfClosing);
展开
type: string
内部 wikitext。
var {firstChild} = Parser.parse('<pre>a</pre>');
assert.equal(firstChild, '<pre>a</pre>');
assert.strictEqual(firstChild.innerText, 'a');
✅ 展开
报告潜在语法错误。
var root = Parser.parse('<b title="a<ref>aa</ref>">aaa</b>'),
ref = root.querySelector('ext#ref');
assert.equal(ref, '<ref>aa</ref>');
assert.deepStrictEqual(ref.lint(), [
{
severity: 'error',
message: 'extension tag in HTML tag attributes',
startLine: 0,
startCol: 11,
startIndex: 11,
endLine: 0,
endCol: 24,
endIndex: 24,
excerpt: '<b title="a<ref>aa</ref>">aaa</b>',
}
]);
展开
returns: this
深拷贝节点。
var {firstChild, lastChild} = Parser.parse('<ref name="a">a</ref><ref name="a"/>'),
closed = firstChild.cloneNode(),
selfClosing = lastChild.cloneNode();
assert.equal(firstChild, '<ref name="a">a</ref>');
assert.equal(closed, '<ref name="a">a</ref>');
assert.equal(lastChild, '<ref name="a"/>');
assert.equal(selfClosing, '<ref name="a"/>');
assert.deepStrictEqual(closed, firstChild);
assert.deepStrictEqual(selfClosing, lastChild);
对维基文本批量执行语法检查的命令行工具
用于维基文本的 ESLint 插件
A command-line tool that performs linting on Wikitext in bulk
ESLint plugin for Wikitext