-
Notifications
You must be signed in to change notification settings - Fork 2
CommentToken (EN)
bhsd edited this page Jun 3, 2024
·
10 revisions
HTML comment.
✅ Available in the Mini and Browser versions.
✅ Expand
type: boolean
Whether the comment is closed.
// closed
var {firstChild} = Parser.parse('<!--');
assert.equal(firstChild, '<!--');
assert(!firstChild.closed);
firstChild.closed = true;
assert.equal(firstChild, '<!---->');
✅ Expand
type: string
The text content of the comment.
// innerText
var {firstChild} = Parser.parse('<!--a-->');
assert.equal(firstChild, '<!--a-->');
assert.strictEqual(firstChild.innerText, 'a');
// innerText (main)
var {firstChild} = Parser.parse('<!--a-->');
firstChild.innerText = 'b';
assert.equal(firstChild, '<!--b-->');
Expand
type: true
CommentToken is invisible, read-only.
// hidden (main)
var {firstChild} = Parser.parse('<!--a-->');
assert.equal(firstChild, '<!--a-->');
assert(firstChild.hidden);
✅ Expand
returns: LintError[]
Report potential grammar errors.
// lint
var {firstChild} = Parser.parse('<!--');
assert.equal(firstChild, '<!--');
assert.deepStrictEqual(firstChild.lint(), [
{
rule: 'unclosed-comment',
severity: 'error',
message: 'unclosed HTML comment',
startLine: 0,
startCol: 0,
startIndex: 0,
endLine: 0,
endCol: 4,
endIndex: 4,
fix: {
range: [4, 4],
text: '-->',
},
},
]);
Expand
returns: this
Deep clone the node.
// cloneNode (main)
var {firstChild, lastChild} = Parser.parse('<!--a--><!--b'),
closed = firstChild.cloneNode(),
open = lastChild.cloneNode();
assert.equal(firstChild, '<!--a-->');
assert.equal(closed, '<!--a-->');
assert.equal(lastChild, '<!--b');
assert.equal(open, '<!--b');
assert.deepStrictEqual(closed, firstChild);
assert.deepStrictEqual(open, lastChild);
对维基文本批量执行语法检查的命令行工具
用于维基文本的 ESLint 插件
A command-line tool that performs linting on Wikitext in bulk
ESLint plugin for Wikitext