UNPKG

wikiparser-node

Version:

A Node.js parser for MediaWiki markup with AST

92 lines (91 loc) 3.02 kB
import Parser from '../index'; import { Token } from './index'; import { AtomToken } from './atom'; import type { LintError, AST } from '../base'; import type { AttributesToken } from '../internal'; declare type Child = AtomToken | AttributeToken | undefined; export type AttributeTypes = 'ext-attr' | 'html-attr' | 'table-attr'; /** * attribute of extension and HTML tags * * 扩展和HTML标签属性 * @classdesc `{childNodes: [AtomToken, Token|AtomToken]}` */ export declare abstract class AttributeToken extends Token { #private; readonly name: string; readonly childNodes: readonly [AtomToken, Token]; abstract get firstChild(): AtomToken; abstract get lastChild(): Token; abstract get parentNode(): AttributesToken | undefined; abstract get nextSibling(): Child; abstract get previousSibling(): Child; abstract get children(): [AtomToken, Token]; abstract get firstElementChild(): AtomToken; abstract get lastElementChild(): Token; abstract get parentElement(): AttributesToken | undefined; abstract get nextElementSibling(): Child; abstract get previousElementSibling(): Child; get type(): AttributeTypes; /** tag name / 标签名 */ get tag(): string; /** whether the quotes are balanced / 引号是否匹配 */ get balanced(): boolean; set balanced(value: boolean); /** attribute value / 属性值 */ get value(): string | true; set value(value: string | true); /** * @param type 标签类型 * @param tag 标签名 * @param key 属性名 * @param equal 等号 * @param value 属性值 * @param quotes 引号 */ constructor(type: AttributeTypes, tag: string, key: string, equal?: string, value?: string, quotes?: readonly [string?, string?], config?: Parser.Config, accum?: Token[]); /** * Get the attribute value * * 获取属性值 */ getValue(): string | true; escape(): void; cloneNode(): this; /** * Close the quote * * 闭合引号 */ close(): void; /** * Set the attribute value * * 设置属性值 * @param value attribute value / 属性值 * @throws `RangeError` 扩展标签属性不能包含 ">" * @throws `RangeError` 同时包含单引号和双引号 */ setValue(value: string | boolean): void; /** * Rename the attribute * * 修改属性名 * @param key new attribute name / 新属性名 * @throws `Error` title和alt属性不能更名 */ rename(key: string): void; /** * Get or set the value of a style property * * 获取或设置某一样式属性的值 * @param key style property / 样式属性 * @param value style property value / 样式属性值 * @throws `Error` 不是style属性 * @throws `Error` 复杂的style属性 * @throws `Error` 无CSS语言服务 * @since v1.17.1 */ css(key: string, value?: string): string | undefined; } export {};