tag-soup
Version:
The fastest pure JS SAX/DOM XML/HTML parser.
47 lines (46 loc) • 1.45 kB
TypeScript
import { Node } from 'flyweight-dom';
import { type ResolvedSerializerOptions } from './serializeMarkup.js';
/**
* Options of {@link createSerializer}.
*
* @group Serializer
*/
export interface SerializerOptions {
/**
* The list of tags that can't have any contents (since there's no end tag, no content can be put between the start
* tag and the end tag).
*
* @example
* ['link', 'meta']
* @see [HTML5 Void Elements](https://www.w3.org/TR/2010/WD-html5-20101019/syntax.html#void-elements)
*/
voidTags?: string[];
/**
* If `true` then ASCII alpha characters are case-insensitive in tag names.
*
* @default false
*/
areTagNamesCaseInsensitive?: boolean;
/**
* If `true` then self-closing tags are recognized, otherwise they are treated as start tags.
*
* @default false
*/
areSelfClosingTagsSupported?: boolean;
/**
* Encodes text content. Use this method to encode HTML/XML entities.
*
* @param text Text to encode.
*/
encodeText?: (text: string) => string;
}
/**
* Serializes DOM node as HTML/XML string.
*
* @param options Serialization options.
* @see {@link toHTML}
* @see {@link toXML}
* @group Serializer
*/
export declare function createSerializer(options?: SerializerOptions): (node: Node) => string;
export declare function resolveSerializerOptions(options: SerializerOptions): ResolvedSerializerOptions;