/** * @file * * The link reference definitions and footnote definitions a note holds inside its containers: its blockquotes, * callouts, list items and footnote definitions, at any depth. Obsidian's metadata worker walks the whole parsed tree * for them, so a definition inside a container counts as one at the top level does. * * Each container's text is read with its prefix stripped from every line, the way `remark-parse` 8 reads a container's * blocks: * * - A blockquote's `>` and the one space after it. A callout's first line, its header, is left out. * - On a list item's first line, its marker, the whitespace up to its content column and its checkbox. On its later * lines, the least indent among the ones indented past the item's container, up to the marker's width with the spaces * after it, which is one column wider than the content for a widened ordered marker. * - On a footnote definition's first line, its label and the whitespace after it. On its later lines, up to four * columns of whitespace. * * The stripped text goes through the same block scan the top level does, so a definition still cannot interrupt a * paragraph, and a blockquote or a footnote definition found there is read the same way in turn. A list item is read by * itself, from the parser's own list items, and a definition the scan of an enclosing container finds inside one is left * to it. * * Approximated: a list inside a footnote definition is not one the parser finds, so a definition in its items is missed. */ import type { ListItemCache, SectionCache } from 'obsidian'; /** * A definition found inside a container. */ export interface ContainerDefinition { /** * The offset just past it, in the note. */ readonly end: number; /** * The offset of the end of its label, the `:` included, in the note; the label of a footnote definition is no * reference to it. */ readonly labelEnd: number; /** * The offset it starts at, in the note. */ readonly start: number; /** * Its text, with the containers' prefixes stripped from each line. */ readonly text: string; /** * Its section type, as the top level reports it. */ readonly type: 'definition' | 'footnoteDefinition'; } /** * What {@link findContainerDefinitions} needs. */ export interface FindContainerDefinitionsParams { /** * The note's full text. */ readonly content: string; /** * The note's list items, at every depth. */ readonly listItems: readonly ListItemCache[]; /** * The note's top-level sections. */ readonly sections: readonly SectionCache[]; } /** * Finds the definitions a note holds inside its blockquotes, callouts and list items. * * @param params - The note, its top-level sections and its list items. * @returns The definitions, in no particular order. */ export declare function findContainerDefinitions(params: FindContainerDefinitionsParams): ContainerDefinition[];