Skip to content

reference-definition

Edits the destination of a reference-style link definition ([id]: destination "title") that Obsidian reports in CachedMetadata.referenceLinks.

Read from Obsidian 1.15.1: a definition’s position spans the whole definition, its leading indentation included and any blockquote or list marker excluded, and its link is the destination with the angle brackets removed and every backslash escape resolved (Target\#Escaped.md reports Target#Escaped.md). The uses of a definition ([text][id], [id][], [id]) are not reported in links and name the definition by its id, so rewriting only the destination keeps every one of them pointing at the new target.

Interface Description
ReferenceDefinitionToFileChangeParams Parameters for referenceDefinitionToFileChange.
Function Description
referenceDefinitionToFileChange Builds the file change that replaces the destination of a reference-style link definition, leaving its id, its title and the rest of the note unchanged. The destination keeps its form: one written in angle brackets stays in them, and a bare one stays bare unless the new destination cannot be written bare (it is empty, holds whitespace or a control character, starts with <, or has unbalanced parentheses), in which case it is written in angle brackets. Characters that would end or change the destination are escaped with a backslash.