-
Notifications
You must be signed in to change notification settings - Fork 2
TrToken (EN)
bhsd edited this page Dec 18, 2023
·
10 revisions
Table row.
✅ Available in the Mini and Browser versions.
✅ Expand
returns: LintError[]
Report potential grammar errors.
// lint
var tr = Parser.parse('{|\n|-\na\n|}').querySelector('tr');
assert.equal(tr, '\n|-\na');
assert.deepStrictEqual(tr.lint(), [
{
severity: 'error',
message: 'content to be moved out from the table',
startLine: 2,
startCol: 0,
startIndex: 6,
endLine: 2,
endCol: 1,
endIndex: 7,
excerpt: 'a',
},
]);
Expand
returns: this
Deep clone the node.
// cloneNode
var tr = Parser.parse('{|\n|-\n|a\n|}').querySelector('tr');
assert.equal(tr, '\n|-\n|a');
assert.deepStrictEqual(tr.cloneNode(), tr);
Expand
returns: number
Get the number of columns.
// getColCount
var tr = Parser.parse('{|\n|-\n|a\n|}').querySelector('tr');
assert.equal(tr, '\n|-\n|a');
assert.strictEqual(tr.getColCount(), 1);
Expand
returns: this
Get the next row.
// getNextRow
var [a, b] = Parser.parse('{|\n|-\n|a\n|-\n!b\n|}').querySelectorAll('tr');
assert.equal(a, '\n|-\n|a');
assert.equal(b, '\n|-\n!b');
assert.strictEqual(a.getNextRow(), b);
Expand
returns: this
Get the previous row.
// getPreviousRow
var [a, b] = Parser.parse('{|\n|-\n|a\n|-\n!b\n|}').querySelectorAll('tr');
assert.equal(a, '\n|-\n|a');
assert.equal(b, '\n|-\n!b');
assert.strictEqual(b.getPreviousRow(), a);
Expand
param: number
Column index
returns: TdToken
Get the n
th column.
// getNthCol
var tr = Parser.parse('{|\n|-\n|a\n|}').querySelector('tr'),
{lastChild} = tr;
assert.equal(tr, '\n|-\n|a');
assert.deepStrictEqual(tr.getNthCol(0), lastChild);
Expand
param: string
Text content of the new cell
param: {column: number}
Coordinates of the new cell
param: string
Subtype of the new cell
param: Record<string, string | number>
Attributes of the new cell
returns: TdToken
Insert a new cell.
// insertTableCell
var tr = Parser.parse('{|\n|-\n|a\n|}').querySelector('tr'),
{lastChild} = tr;
assert.equal(tr, '\n|-\n|a');
tr.insertTableCell('b', {column: 1}, 'th', {rowspan: 2});
assert.equal(tr.toString(), '\n|-\n|a\n!rowspan="2"|b');
对维基文本批量执行语法检查的命令行工具
用于维基文本的 ESLint 插件
A command-line tool that performs linting on Wikitext in bulk
ESLint plugin for Wikitext