UNPKG

@grammar/html

Version:

HTML grammar.

144 lines 4.78 kB
import $ from './spellu-engine'; declare namespace grammar$html { } declare namespace grammar$html { const enum Syntax { TagName = "html.TagName", AttributeName = "html.AttributeName", StringLiteral = "html.StringLiteral", NumericLiteral = "html.NumericLiteral", Text = "html.Text", HtmlDocument = "html.HtmlDocument", XmlDeclaration = "html.XmlDeclaration", DoctypeDeclaration = "html.DoctypeDeclaration", ElementDeclaration = "html.ElementDeclaration", Attribute = "html.Attribute", TagSection = "html.TagSection", TextSection = "html.TextSection", CDataSection = "html.CDataSection", CommentSection = "html.CommentSection" } const enum Syntax { XmlDeclarationOpenToken = "html.token.XmlDeclaration.L", XmlDeclarationCloseToken = "html.token.XmlDeclaration.R", MarkupDeclarationOpenToken = "html.token.MarkupDeclaration.L", MarkupDeclarationCloseToken = "html.token.MarkupDeclaration.R", MarkupDeclarationKeywordToken = "html.token.MarkupDeclaration.keyword", DoubleHyphenToken = "html.token.doublehyphen", TagOpenToken = "html.token.<", TagCloseToken = "html.token.>", SlashToken = "html.token./", EqualToken = "html.token.=" } interface Node extends $.Node { } interface Token extends $.Token { } interface Document extends Node { syntax: Syntax.HtmlDocument; xmlDeclaration: XmlDeclaration | null; doctype: DoctypeDeclaration | null; nodeList: Node[]; } interface XmlDeclaration extends Node { syntax: Syntax.XmlDeclaration; attributeList: Attribute[]; } interface DoctypeDeclaration extends Node { syntax: Syntax.DoctypeDeclaration; string: Token; } interface Element extends Node { syntax: Syntax.ElementDeclaration; tagName: Token; attributeList: Attribute[]; nodeList: Node[]; void: boolean; } interface Tag extends Node { syntax: Syntax.TagSection; isOpen: boolean; isClose: boolean; tagName: Token; attributeList: Attribute[]; } interface Text extends Node { syntax: Syntax.TextSection; text: Token; } interface CData extends Node { syntax: Syntax.CDataSection; text: Token; } interface Comment extends Node { syntax: Syntax.CommentSection; text: Token; } interface Attribute extends Node { name: Token; value: Token; } } /** * HTML 5 * */ declare namespace grammar$html { function createRecipe(): $.Recipe; } declare namespace grammar$html.processors { const cst: $.Processor; } declare namespace grammar$html.processors { const ast: $.Processor; } declare namespace grammar$html { interface SourceVisitor<T> { visitXmlDeclaration?(value: T, node: XmlDeclaration): T; visitDoctypeDeclaration?(value: T, node: DoctypeDeclaration): T; visitElementBefore?(value: T, node: Element): T; visitElementAfter?(value: T, node: Element): T; visitTag?(value: T, node: Tag): T; visitText?(value: T, node: Text): T; visitComment?(value: T, node: Comment): T; visitCData?(value: T, node: CData): T; onError?(value: T, node: Node): T; } class SourceWalker<T> { protected visitor: SourceVisitor<T>; constructor(visitor: SourceVisitor<T>); walk(initialValue: T, source: Document): T; walkElement(value: T, element: Element): T; walkNode(value: T, node: Node): T; } } declare namespace grammar$html { function isVoidTag(tagName: string): boolean; } declare namespace grammar$html { enum ProcessorSuite { CST = "cst", AST = "ast" } function selectProcessorSuite(processor: ProcessorSuite): $.Processor[]; function scan<V>(source: string | $.SourceDescriptor, suite?: ProcessorSuite, rule?: string, options?: Partial<$.ScanOptions>): V; function tokens(source: string | $.SourceDescriptor, options?: Partial<$.ScanOptions>): Token[]; } declare namespace grammar$html { type PrintOptions = { pretty?: boolean; format?: 'html' | 'xml'; }; export function printSource(document: Document, options?: PrintOptions): string; export {}; } declare namespace grammar$html { function assemble(source: Document): Document; } declare namespace grammar$html { function checkStrict(source: Document): void; } declare namespace grammar$html { function createDocument(...nodes: Node[]): Document; } export default grammar$html; //# sourceMappingURL=grammar-html.d.ts.map