wikiparser-node
Version: 
A Node.js parser for MediaWiki markup with AST
66 lines (65 loc) • 2.03 kB
TypeScript
import { TableBaseToken } from './base';
import { TdToken } from './td';
import type { LintError } from '../../base';
import { Token } from '../index';
import type { TdAttrs, TdSubtypes } from './td';
import type { AstNodes, SyntaxToken, TrToken } from '../../internal';
export interface TableCoords {
    readonly row: number;
    readonly column: number;
    readonly x?: undefined;
    readonly y?: undefined;
    readonly start?: boolean;
}
/**
 * table row or table
 *
 * 表格行或表格
 */
export declare abstract class TrBaseToken extends TableBaseToken {
    #private;
    abstract get type(): 'table' | 'tr';
    /**
     * Get the number of rows
     *
     * 获取行数
     */
    getRowCount(): number;
    /**
     * Get the `n`-th column
     *
     * 获取第n列
     * @param n column number / 列号
     * @param insert whether to be used to insert a new column / 是否用于判断插入新列的位置
     * @throws `RangeError` 不存在对应单元格
     */
    getNthCol(n: number, insert?: false): TdToken | undefined;
    getNthCol(n: number, insert: true): TdToken | TrToken | SyntaxToken | undefined;
    /**
     * @override
     * @param i position of the child node / 移除位置
     */
    removeAt(i: number): AstNodes;
    /**
     * @override
     * @param token node to be inserted / 待插入的子节点
     * @param i position to be inserted at / 插入位置
     */
    insertAt<T extends Token>(token: T, i?: number): T;
    /**
     * Get the number of columns
     *
     * 获取列数
     */
    getColCount(): number;
    /**
     * Insert a new cell
     *
     * 插入新的单元格
     * @param inner inner wikitext of the cell / 单元格内部wikitext
     * @param {TableCoords} coord table coordinates of the cell / 单元格坐标
     * @param subtype cell type / 单元格类型
     * @param attr cell attribute / 单元格属性
     */
    insertTableCell(inner: string | Token, { column }: TableCoords, subtype?: TdSubtypes, attr?: TdAttrs): TdToken;
}