/** * Chinese and Japanese inline annotations (#193, #194, #195, #421, #430): * emphasis dots (`:dots[…]`), the proper-name and book-title marks * (`:name[…]`, `:book[…]`), side lines (傍線, `:sideline[…]{style pos}`), * kanbun reading marks (訓点, `:kunten[字]{kaeri okuri tate}`), ruby * (`:ruby[…]{rt="…" mode align}` and the compact `{紅樓|hóng|lóu}`) and * warichu notes (`:warichu[…]{open close}`); and the directional isolates * (`:rtl[…]`, `:ltr[…]`, with an optional `{lang=…}`, #367), which set a * run in its own direction inside text of the other. * * They preserve their text, as `:smallcaps[…]` does: the characters between * the brackets stay in the paragraph's plain text (search, the contents, * index anchors and the source map see them), and the mark becomes a field * of the spans that hold them. {@link markAnnotations} replaces each * directive by private-use marks around its content, before the emphasis * scanners run, and queues its attributes (so `*` or `_` inside a reading * never reach them); {@link applyAnnotationMarks} turns the marks into span * fields once the spans exist. The content may hold other inline marks, * nested annotations included (`:warichu[甲戌側批::name[寶玉]…]`). */ import type { DirectiveAttrs, InlineSpan } from './types.js'; /** The inline annotation directives, by name. */ export declare const ANNOTATION_NAMES: readonly ["dots", "name", "book", "ruby", "warichu", "ltr", "rtl", "sideline", "kunten"]; export type AnnotationName = (typeof ANNOTATION_NAMES)[number]; /** One annotation as written: its kind, its attributes, and (a compact * ruby) its readings. Queued in the order of the marks in the text. */ export interface QueuedAnnotation { name: AnnotationName; attrs: DirectiveAttrs; /** The readings of a compact ruby (`{紅樓|hóng|lóu}`), one per `|`. */ readings?: string[]; } /** * The index of the `]` closing the `[` at `open`, brackets nested inside * counting and a backslash escaping the character after it; -1 when the * line ends first (or `end` is reached). */ export declare function closingBracket(text: string, open: number, end?: number): number; /** One annotation found in a text: where its opener, content and closer * (its attribute blob included) sit. */ export interface FoundAnnotation { name: AnnotationName; /** `[start, contentStart)`: `:name[` or a compact ruby's `{`. */ start: number; contentStart: number; /** `[contentEnd, end)`: `]` and its `{…}`, or a compact ruby's `|…}`. */ contentEnd: number; end: number; attrs: string | undefined; compact?: boolean; } /** * Replace every annotation of `text` by its content between the private-use * marks, pushing each one's attributes on `queue` in text order. A * directive whose bracket never closes on its line stays text. `restore` * turns the escape placeholders of an attribute value back into the * characters written. */ export declare function markAnnotations(text: string, queue: QueuedAnnotation[], restore?: (s: string) => string): string; /** `text` with every annotation reduced to its content (the plain text of * a running head, an index term, a contents row): `boundary` is left where * each mark was. */ export declare function stripAnnotations(text: string, boundary?: string): string; /** Whether a text holds annotation marks (see {@link markAnnotations}). */ export declare function hasAnnotationMarks(text: string): boolean; /** * Split the spans at the annotation marks, setting the fields of each * annotation on the spans between its marks and dropping the marks (and * any piece left empty). `queue` holds the annotations in the order of * their marks (see {@link markAnnotations}); ids count from 1 per call, so * a paragraph parsed twice gets the same ones. A mono ruby becomes one span * per base character; a group ruby one span (in its first piece's style). */ export declare function applyAnnotationMarks(spans: InlineSpan[], queue: readonly QueuedAnnotation[]): InlineSpan[]; /** The fields of an annotation a span carries, for a pass that cuts a span * into pieces (a placeholder injected inside it): every piece keeps them. * `withRuby` keeps a ruby too (a text piece; never the placeholder). */ export declare function annotationFields(span: InlineSpan, withRuby?: boolean): Partial; /** * Where the annotations of a stretch of source (`[from, end)` of * `markdown`) put markup the plain text does not print: each opener * (`:dots[`, a compact ruby's `{`) and each closer (`]` with its `{…}`, a * compact ruby's `|…}`), sorted. `computeSourceMap` steps over them, so a * plain space after `:ruby[紅]{rt="hóng lóu"}` never maps into the reading. * Inline code is left alone, as the parser leaves it. */ export declare function annotationSourceSkips(markdown: string, from: number, end: number): Array<[number, number]>; /** * Every annotation of a line of source, nested ones included, in order of * their openers (for an editor's highlighting): its kind, the opener * (`[start, contentStart)`), the text (`[contentStart, contentEnd)`) and the * closer with its attributes or readings (`[contentEnd, end)`). */ export declare function findAnnotations(text: string): FoundAnnotation[]; /** An opening and a closing bracket (`cjk.bookTitleBrackets`). */ export interface BracketPair { open: string; close: string; } /** The brackets of `pairs` around the titles of `:book[…]` (`《》` and * `〈〉` for a title inside one unless `pairs` says otherwise; a title * nested deeper than the list takes its last pair), as spans flagged * `inserted` (they take no character of the plain text); the titles lose * their `bookTitle`. A bracket written empty is left out. * `cjk.bookTitleMark: 'brackets'` with `cjk.bookTitleBrackets`. */ export declare function withBookBrackets(spans: readonly InlineSpan[], pairs?: readonly BracketPair[]): InlineSpan[]; //# sourceMappingURL=annotations.d.ts.map