/** * Defines the valid types for an HTML attribute name. * @typedef {never|string} Attribute */ export type Attribute = never | string; export type HtmlRegexConfig = { /** * - The HTML tag name (e.g., 'a', 'div'). */ tagName: TagName; /** * - An array of attribute names to capture in individual groups. */ attributes?: Attributes[]; /** * - If true, allows the inner content to contain newlines. */ freeMode?: boolean; /** * - If true, ignores specific attributes and focuses on the tag structure. */ captureAllAttributes: CaptureAllAttributes; /** * - The regex pattern for the tag's inner content. */ contentPattern?: string; }; export type ParsedHtmlTag = { /** * - Object containing all parsed attributes. */ attributes: Record; /** * - The inner content of the HTML tag. */ child: string; }; /** * Configuration object used to define the parameters for the regex builder. * @template {string} TagName * @template {boolean} CaptureAllAttributes * @template {Attribute} Attributes * @typedef {Object} HtmlRegexConfig * @property {TagName} tagName - The HTML tag name (e.g., 'a', 'div'). * @property {Attributes[]} [attributes=[]] - An array of attribute names to capture in individual groups. * @property {boolean} [freeMode=false] - If true, allows the inner content to contain newlines. * @property {CaptureAllAttributes} captureAllAttributes - If true, ignores specific attributes and focuses on the tag structure. * @property {string} [contentPattern='[\s\S]*?'] - The regex pattern for the tag's inner content. */ /** * Represents the structured result of a parsed HTML tag. * @typedef {Object} ParsedHtmlTag * @property {Record} attributes - Object containing all parsed attributes. * @property {string} child - The inner content of the HTML tag. */ /** * Class responsible for constructing highly configurable regular expressions * to capture HTML tags and their specific attributes. * @template {string} TagName * @template {boolean} CaptureAllAttributes * @template {Attribute} Attributes */ declare class TinyHtmlTagRegexBuilder { #private; /** * Initializes a new instance of the TinyHtmlTagRegexBuilder. * @param {HtmlRegexConfig} config - Initial configuration object. */ constructor(config: HtmlRegexConfig); /** * Gets the target HTML tag name. * @returns {TagName} */ get tagName(): TagName; /** * Gets a copy of the attributes to be captured. * @returns {Attributes[]} */ get attributes(): Attributes[]; /** * Gets the current free mode status. * @returns {boolean} */ get freeMode(): boolean; /** * Sets the free mode status. * @param {boolean} value */ set freeMode(value: boolean); /** * Gets the attribute capture mode. * @returns {CaptureAllAttributes} */ get captureAllAttributes(): CaptureAllAttributes; /** * Gets the current regex pattern for the tag's content. * @returns {string} */ get contentPattern(): string; /** * Sets the regex pattern for the tag's content. * @param {string} value */ set contentPattern(value: string); /** * Constructs the RegExp string. * @returns {string} The constructed regular expression string. */ toString(): string; /** * Constructs and returns the final RegExp object. * @param {string} [flag='g'] * @returns {RegExp} The configured regular expression. */ toRegExp(flag?: string): RegExp; /** * Executes the generated regex against an HTML string and organizes the results. * * @param {string} htmlString - The HTML text to be parsed. * @returns {ParsedHtmlTag[]} An array containing an object for each matched tag, with its attributes and child. */ parse(htmlString: string): ParsedHtmlTag[]; } export default TinyHtmlTagRegexBuilder; //# sourceMappingURL=TinyHtmlTagRegexBuilder.d.mts.map