UNPKG

wikiparser-node

Version:

A Node.js parser for MediaWiki markup with AST

69 lines (68 loc) 2.15 kB
import { Token } from './index'; import type { Config, LintError, AST } from '../base'; import type { AttributesParentBase } from '../mixin/attributesParent'; import type { AttributesToken } from '../internal'; import type { AstRange } from '../lib/range'; export interface HtmlToken extends AttributesParentBase { } /** * HTML tag * * HTML标签 * @classdesc `{childNodes: [AttributesToken]}` */ export declare abstract class HtmlToken extends Token { #private; readonly name: string; readonly childNodes: readonly [AttributesToken]; abstract get firstChild(): AttributesToken; abstract get lastChild(): AttributesToken; abstract get children(): [AttributesToken]; abstract get firstElementChild(): AttributesToken; abstract get lastElementChild(): AttributesToken; get type(): 'html'; /** whether to be self-closing / 是否自封闭 */ get selfClosing(): boolean; /** whether to be a closing tag / 是否是闭合标签 */ get closing(): boolean; /** @throws `Error` 自封闭标签或空标签 */ set closing(value: boolean); /** @throws `Error` 闭合标签或无效自封闭标签 */ set selfClosing(value: boolean); /** * @param name 标签名 * @param attr 标签属性 * @param closing 是否闭合 * @param selfClosing 是否自封闭 */ constructor(name: string, attr: AttributesToken, closing: boolean, selfClosing: boolean, config?: Config, accum?: Token[]); /** * Find the matching tag * * 搜索匹配的标签 */ findMatchingTag(): this | undefined; cloneNode(): this; /** * Change the tag name * * 更换标签名 * @param tag tag name / 标签名 * @throws `RangeError` 非法的HTML标签 */ replaceTag(tag: string): void; /** * Fix the invalid self-closing tag * * 修复无效自封闭标签 * @throws `Error` 无法修复无效自封闭标签 */ fix(): void; /** * Get the range of the HTML tag pair * * 获取HTML标签对的范围 * @since v1.23.0 */ getRange(): AstRange | undefined; }