/** * @file * * Block ids, assigned the way Obsidian's metadata worker assigns them once it has parsed a note. An id is `^` and a run * of letters, digits and `-`, read in two places: * * - Inline, at the end of a paragraph's or a heading's text, or of the content of an inline token in it, where the `^` * starts that text, follows whitespace, or follows another inline token (see `markdown-inline-block-ids.ts`). Trailing * whitespace after the id spoils it. * - Standalone, as a block of its own (see `markdown-gap-blocks.ts`). Its id goes to the top-level section before it, * whatever that section is, and the block itself is dropped, so a note opening with one keeps no trace of it. * * A top-level section takes the LAST id found anywhere inside it, a standalone one after it overriding that. A list * section takes none of its own, only a standalone one after it; each of its items takes the FIRST id in its own blocks, * the lists nested in it left out. `blocks` keys every id lower-cased, sections first and list items after them. */ import type { BlockCache, HeadingCache, ListItemCache, SectionCache } from 'obsidian'; import type { FootnoteSource } from './markdown-references.cjs'; /** * What {@link assignBlockIds} needs. */ export interface AssignBlockIdsParams { /** * The note's full text. */ readonly content: string; /** * The footnotes the note references, which the `element` section Obsidian appends for them holds. */ readonly footnoteSources: readonly FootnoteSource[]; /** * The note's headings, which hold the text an ATX or setext heading's id is read from. */ readonly headings: readonly HeadingCache[]; /** * The note's list items, each of which is given the id it holds. */ readonly listItems: readonly ListItemCache[]; /** * The note's sections, sorted, standalone block ids among them; those are removed, and every other section is given * the id it holds. */ readonly sections: SectionCache[]; } /** * The type of the section Obsidian's worker appends to a note that references a footnote: the list of those footnotes. */ export declare const FOOTNOTE_LIST_SECTION_TYPE = "element"; /** * Assigns the block ids of a note's sections and list items, and drops its standalone block ids. * * @param params - The note, its sections, headings and list items. * @returns The `blocks` collection: each id, lower-cased, to the section or list item that holds it. */ export declare function assignBlockIds(params: AssignBlockIdsParams): Record;