import Parser from '../index'; import { AstElement } from '../lib/element'; import { AstText } from '../lib/text'; import type { TokenTypes, LintError } from '../base'; import type { Title, TitleOptions } from '../lib/title'; import type { AstNodes, IncludeToken, HtmlToken, ExtToken, CommentToken } from '../internal'; import { Ranges } from '../lib/ranges'; import type { Range } from '../lib/ranges'; import type { AstRange as AstRangeBase } from '../lib/range'; declare type ExtendedLintError = LintError[] & { output?: string; }; /** * base class for all tokens * * 所有节点的基类 * @classdesc `{childNodes: (AstText|Token)[]}` */ export declare class Token extends AstElement { #private; get type(): TokenTypes; set type(value: TokenTypes); /** * page name * * 页面名称 * @since v1.29.0 */ get pageName(): string | undefined; set pageName(value: string | undefined); /** @class */ constructor(wikitext?: string, config?: Parser.Config, accum?: Token[], acceptable?: WikiParserAcceptable); /** * @override * @param child node to be inserted / 待插入的子节点 * @param i position to be inserted at / 插入位置 */ insertAt(child: string, i?: number): AstText; insertAt(child: T, i?: number): T; /** * Normalize page title * * 规范化页面标题 * @param title title (with or without the namespace prefix) / 标题(含或不含命名空间前缀) * @param defaultNs default namespace number / 命名空间 */ normalizeTitle(title: string, defaultNs?: number, opt?: TitleOptions): Title; /** * Replace with a token of the same type * * 替换为同类节点 * @param token token to be replaced with / 待替换的节点 * @throws `Error` 不存在父节点 */ safeReplaceWith(token: this): void; /** * Create an HTML comment * * 创建HTML注释 * @param data comment content / 注释内容 */ createComment(data?: string): CommentToken; /** * Create a tag * * 创建标签 * @param tagName tag name / 标签名 * @param options options / 选项 * @param options.selfClosing whether to be a self-closing tag / 是否自封闭 * @param options.closing whether to be a closing tag / 是否是闭合标签 */ createElement(tagName: string, options?: { selfClosing?: boolean; closing?: boolean; }): IncludeToken | ExtToken | HtmlToken; /** * Create a text node * * 创建纯文本节点 * @param data text content / 文本内容 */ createTextNode(data?: string): AstText; /** * Create an AstRange object * * 创建AstRange对象 */ createRange(): AstRangeBase; /** * Check if a title is an interwiki link * * 判断标题是否是跨维基链接 * @param title title / 标题 */ isInterwiki(title: string): RegExpExecArray | null; /** * Deep clone the node * * 深拷贝节点 */ cloneNode(): this; /** * Get all sections * * 获取全部章节 */ sections(): AstRangeBase[] | undefined; /** * Get a section * * 获取指定章节 * @param n rank of the section / 章节序号 */ section(n: number): AstRangeBase | undefined; /** * Get the enclosing HTML tags * * 获取指定的外层HTML标签 * @param tag HTML tag name / HTML标签名 */ findEnclosingHtml(tag?: string): AstRangeBase | undefined; /** * Get all categories * * 获取全部分类 */ getCategories(): [string, string | undefined][]; /** * Expand templates * * 展开模板 * @since v1.10.0 */ expand(): Token; /** * Parse some magic words * * 解析部分魔术字 */ solveConst(): Token; /** * Merge plain child tokens of a plain token * * 合并普通节点的普通子节点 */ flatten(): void; /** * Generate HTML * * 生成HTML * @since v1.10.0 */ toHtml(): string; /** * Build lists * * 构建列表 * @since v1.17.1 */ buildLists(): void; } export {};