import { FragmentPosition, FragmentReverseTransformation } from './fragments.js'; export interface SourceMapSegment { inputIndex: number; inputLength: number; matchingSegmentIndex?: number; /** * Added only by `convertHtmlElementsToText` * * It allows `iterOriginalMergedPositionsFromTransformed` function * to reorganize HTML elements. */ openingTag?: string; outputIndex: number; outputLength: number; } export type Transformation = TransformationLeaf | TransformationNode; export interface TransformationLeaf { input: string; output: string; sourceMap: SourceMapSegment[]; title: string; } export interface TransformationNode { input: string; output: string; transformations: Transformation[]; title: string; } export type Transformer = (text: string) => Transformation; export type TransformerLeaf = (text: string) => TransformationLeaf; export type TransformerNode = (text: string) => TransformationNode; export declare const tagRegExp: RegExp; export declare function chainTransformers(title: string, transformers: Array): TransformerNode; /** * Creates an iterator that converts transformed (e.g. simplified) positions to original * (e.g. HTML) positions * * When a position is included in fragments of HTML elements, the elements are * either split (for spans) or the position is enlarged to include the whole * elements (for blocks). * * Use this iterator to insert HTML elements (links, spans, etc). */ export declare function newReverseTransformationsMergedFromPositionsIterator(transformation: Transformation): Generator; /** * Converts an array of transformed (e.g. simplified) positions to an array * of arrays of original (e.g. HTML) positions (one array of original positions * for each transformed position) * * Each position is split to ensure that it doesn't contain any HTML element. * * The positions must be sorted in ascending order. * * Use this function for diffs. */ export declare function reversePositionsSplitFromPositions(transformation: Transformation, transformedPositions: FragmentPosition[]): Array; /** * Converts an array of transformed (e.g. simplified) positions to an array * of original (e.g. HTML) positions * * When a position is included in fragments of HTML elements, the elements are * either split (for spans) or the position is enlarged to include the whole * elements (for blocks). * * Use this function to insert HTML elements (links, spans, etc). */ export declare function reverseTransformationsMergedFromPositions(transformation: Transformation, transformedPositions: FragmentPosition[]): FragmentReverseTransformation[]; /** * Use an iterator that converts transformed (e.g. simplified) positions to original * (e.g. HTML) positions, to get an original position from a transformed position. */ export declare function reverseTransformationFromPosition(originalPositionsFromTransformedIterator: Generator, transformedPosition: FragmentPosition): FragmentReverseTransformation; export declare const reverseTransformedInnerFragment: (originalText: string, originalTransformation: FragmentReverseTransformation | undefined, offset?: number) => StringOrUndefined; export declare const reverseTransformedReplacement: (originalTransformation: FragmentReverseTransformation, replacement: string) => string;