Skip to content

parse-link

This module provides utilities for parsing markdown and wiki links into structured data, and for escaping, unescaping, and encoding link components.

Interface Description
ParseFrontmatterLinksResult The result of parsing the links from a note’s frontmatter via parseFrontmatterLinks. Internal single-link frontmatter values are omitted, as Obsidian natively caches them.
ParseLinkFrontmatterReference A FrontmatterLinkCache for a link parsed from a single-link frontmatter value via parseLinks. It carries the full ParseLinkResult so consumers can inspect the parse details without re-parsing the link. Use this when the whole frontmatter value is a single link.
ParseLinkFrontmatterReferenceWithOffsets A ParseLinkFrontmatterReference for a link parsed from a multi-link frontmatter value via parseLinks, additionally carrying the offsets of the link within the frontmatter value. Use this when the frontmatter value holds multiple links.
ParseLinkReference A ReferenceCache for a link parsed from content via parseLinks. It carries the full ParseLinkResult so consumers can inspect the parse details without re-parsing the link.
ParseLinkResult A result of parsing a link.
ParseLinksOptions Options for parseLinks.
ToParseLinkReferenceParams Params for toParseLinkReference.
Function Description
escapeAlias Escapes the alias of a markdown link.
isParseLinkFrontmatterReference Determines whether a reference is a ParseLinkFrontmatterReference.
isParseLinkReference Determines whether a reference is a ParseLinkReference.
parseFrontmatterLinks Parses the links from a note’s frontmatter. Each string value is parsed via parseLinks: a value that is a single link yields an entry without offsets, and a value that holds multiple links yields offset-carrying entries. A value is a single link the way Obsidian reads it, so [A [ B](t.md) is one link captioned A [ B (see parseLink). Internal single-link values are omitted, as Obsidian natively caches them.
parseLink Parses a link into its components. A string that starts with [ and ends with a markdown link is read as ONE link whose caption runs from the leading [ to that link’s ](, the way Obsidian reads a frontmatter value: [A [ B](t.md) has the alias A [ B, where CommonMark finds only [ B](t.md).
parseLinks Parses all links in a string. Besides markdown links, wikilinks and autolinks, the plain text between them is scanned for bare URLs with a scheme (https://example.com) and, unless turned off through ParseLinksOptions.shouldRecognizeWwwAutolinkLiterals, for GFM extended www. autolink literals (www.example.com). Such a literal is reported as an external link whose url carries the http:// scheme Obsidian opens it with, so a link rebuilt from it stays external: a scheme-less [alias](www.example.com) is an internal link in Obsidian. A literal wrapped in <...> reports the brackets as part of raw, so replacing raw leaves no stray bracket behind. Code is never scanned: fenced and indented code blocks, a fence’s info string and inline code hold no link in Obsidian. A bare file: URL is reported only when a slash or a backslash follows the scheme, so a word such as file:python3.py stays text.
toParseLinkReference Wraps a ParseLinkResult into a ParseLinkReference so it can flow through the reference-based file-change pipeline.
unescapeAlias Unescapes the alias of a markdown link.
Type Description
ParseLinkOptions Options for parseLink. The same as ParseLinksOptions.