import { ErrorCodes, CompilerError, createCompilerError } from './errors' import { assert, advancePositionWithMutation } from './utils' import { Namespace, Namespaces, AttributeNode, CommentNode, DirectiveNode, ElementNode, ElementTypes, ExpressionNode, NodeTypes, Position, RootNode, SourceLocation, TextNode, ChildNode } from './ast' export interface ParserOptions { isVoidTag?: (tag: string) => boolean // e.g. img, br, hr getNamespace?: (tag: string, parent: ElementNode | undefined) => Namespace getTextMode?: (tag: string, ns: Namespace) => TextModes delimiters?: [string, string] // ['{{', '}}'] ignoreSpaces?: boolean // Map to HTML entities. E.g., `{ "amp;": "&" }` // The full set is https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references namedCharacterReferences?: { [name: string]: string | undefined } onError?: (error: CompilerError) => void } export const defaultParserOptions: Required = { delimiters: [`{{`, `}}`], ignoreSpaces: true, getNamespace: () => Namespaces.HTML, getTextMode: () => TextModes.DATA, isVoidTag: () => false, namedCharacterReferences: { 'gt;': '>', 'lt;': '<', 'amp;': '&', 'apos;': "'", 'quot;': '"' }, onError(error: CompilerError): void { throw error } } export const enum TextModes { // | Elements | Entities | End sign | Inside of DATA, // | ✔ | ✔ | End tags of ancestors | RCDATA, // | ✘ | ✔ | End tag of the parent |