AK-21/Graphite-Industrial-Intelligence
0
1import type {Point, Position} from 'unist'2 3// To do: next major: remove `void` from allowed return types.4 5/**6 * @typeParam Context7 * Value used as `this`.8 * @this9 * The `warningContext` given to `parseEntities`10 * @param reason11 * Human readable reason for emitting a parse error.12 * @param point13 * Place where the error occurred.14 * @param code15 * Machine readable code the error.16 */17export type WarningHandler<Context = undefined> = (18 this: Context,19 reason: string,20 point: Point,21 code: number22) => undefined | void23 24/**25 * @typeParam Context26 * Value used as `this`.27 * @this28 * The `referenceContext` given to `parseEntities`29 * @param value30 * Decoded character reference.31 * @param position32 * Place where `value` starts and ends.33 * @param source34 * Raw source of character reference.35 */36export type ReferenceHandler<Context = undefined> = (37 this: Context,38 value: string,39 position: Position,40 source: string41) => undefined | void42 43/**44 * @typeParam Context45 * Value used as `this`.46 * @this47 * The `textContext` given to `parseEntities`.48 * @param value49 * String of content.50 * @param position51 * Place where `value` starts and ends.52 */53export type TextHandler<Context = undefined> = (54 this: Context,55 value: string,56 position: Position57) => undefined | void58 59/**60 * Configuration.61 *62 * @typeParam WarningContext63 * Value used as `this` in the `warning` handler.64 * @typeParam ReferenceContext65 * Value used as `this` in the `reference` handler.66 * @typeParam TextContext67 * Value used as `this` in the `text` handler.68 */69export interface Options<70 WarningContext = undefined,71 ReferenceContext = undefined,72 TextContext = undefined73> {74 /**75 * Additional character to accept.76 * This allows other characters, without error, when following an ampersand.77 *78 * @default ''79 */80 additional?: string | null | undefined81 /**82 * Whether to parse `value` as an attribute value.83 * This results in slightly different behavior.84 *85 * @default false86 */87 attribute?: boolean | null | undefined88 /**89 * Whether to allow nonterminated character references.90 * For example, `©cat` for `©cat`.91 * This behavior is compliant to the spec but can lead to unexpected results.92 *93 * @default true94 */95 nonTerminated?: boolean | null | undefined96 /**97 * Starting `position` of `value` (`Point` or `Position`). Useful when dealing with values nested in some sort of syntax tree.98 */99 position?: Readonly<Position> | Readonly<Point> | null | undefined100 /**101 * Context used when calling `warning`.102 */103 warningContext?: WarningContext | null | undefined104 /**105 * Context used when calling `reference`.106 */107 referenceContext?: ReferenceContext | null | undefined108 /**109 * Context used when calling `text`.110 */111 textContext?: TextContext | null | undefined112 /**113 * Warning handler.114 */115 warning?: WarningHandler<WarningContext> | null | undefined116 /**117 * Reference handler.118 */119 reference?: ReferenceHandler<ReferenceContext> | null | undefined120 /**121 * Text handler.122 */123 text?: TextHandler<TextContext> | null | undefined124}125 126export {parseEntities} from './lib/index.js'127 