Skip to content

UpdateReferencesInContentParams

Params for updateReferencesInContent.

Import:

import type { UpdateReferencesInContentParams } from '@mnaoumov/obsidian-lib/link';

Signature:

export interface UpdateReferencesInContentParams

Properties

PropertyTypeDescription
abortSignal?AbortSignalThe abort signal to control the execution of the function.
appAppAn Obsidian app instance.
contentstringA content to update the links in.
isEmptyEmbedAliasAllowed?booleanWhether to allow an empty alias for embeds.

Applicable only if the result link style is LinkStyle.Markdown.

If true: ![](foo.png).

If false: ![foo](foo.png).
linkPathStyle?LinkPathStyleA style of the link path.
linkStyle?LinkStyleA style of the link.
linkStyleProvider?(reference: Reference) => LinkStyle | nullDecides the style of one link, overriding linkStyle for it. Returning null keeps linkStyle.

Use it when one style for the whole content is wrong for some of its links. A caller forcing LinkStyle.Markdown over a note, for example, keeps a frontmatter wikilink a wikilink, because Obsidian reads a property value as a link only in that form.
newSourcePathOrFilePathOrFileA new source path or file.
offsetRange?OffsetRangeA range within UpdateReferencesInContentParams.content, in character offsets, restricting the pass to the links inside it. When omitted, every link is visited.

A link is updated only when it is **fully contained** in the range; one that merely overlaps it is left alone, because rewriting part of a link corrupts it. Both bounds are inclusive, so a range whose offsets coincide exactly with a link's does include that link.

A reference that carries no position within the content — a frontmatter link, a multi-link frontmatter value entry, or any canvas reference — is never in range and is skipped whenever a range is supplied.
oldSourcePathOrFile?PathOrFileAn old source path or file.
shouldEscapeAlias?booleanWhether to escape the alias.

Applicable only if the result link style is LinkStyle.Markdown.

If true: [\*\*alias\*\*](link.md).

If false: [**alias**](link.md).
shouldIncludeAttachmentExtensionToEmbedAlias?booleanWhether to include the attachment extension in the embed alias.

Applicable only if isEmptyEmbedAliasAllowed is false.

If true: [foo.png](foo.png).

If false: [foo](foo.png).
shouldSkipReference?((reference: Reference) => boolean) | nullA predicate choosing links to leave unchanged: for each reference it returns true for, the converter is not called, so the link stays byte-for-byte as written — its path, style, angle brackets and leading dot included. Use it to exclude links the caller decides on, for example by their resolved target path.

Applied after the heading skip and the offset range.

null behaves like an absent key, so a predicate factory that returns null when nothing is excluded can be passed straight through.
shouldSkipReferencesInHeadings?booleanWhether to leave every link inside a heading unchanged: it is neither converted nor restyled, so it stays byte-for-byte as written. A link in a heading is part of the heading's text, so rewriting it changes that text and breaks every #heading subpath pointing at the heading. See isReferenceInHeading.
shouldUpdateEmbedOnlyLinks?booleanWhether to update only embedded links.
shouldUpdateFileNameAlias?booleanWhether to update file name alias.
shouldUseAngleBrackets?booleanIndicates if the link should use angle brackets.

Applicable only if linkStyle is LinkStyle.Markdown.

If true: [alias](<path with spaces.md>).

If false: [alias](path%20with%20spaces.md).
shouldUseLeadingDotForRelativePaths?booleanIndicates if the link should use a leading dot.

Applicable only if linkPathStyle is LinkPathStyle.RelativePathToTheSource.

If true: [[./relative/path/to/target]]

If false: [[relative/path/to/target]]
shouldUseLeadingSlashForAbsolutePaths?booleanIndicates if the link should use a leading slash.

Applicable only if linkPathStyle is LinkPathStyle.AbsolutePathInVault.

If true: [[/absolute/path/to/target]]

If false: [[absolute/path/to/target]]

Links to this page: