class

Hwaro::Services::Importers::ObsidianImporter

Inherits Hwaro::Services::Importers::Base < Reference < Object

Constants

EMBED_PATTERN = /!\[\[([^\]]+?)\]\]/

Obsidian embed pattern: ![[filename]]

HTML_SPAN_PATTERN = /<!--.*?-->|<\/?[A-Za-z][^<>\n]*>/

Spans where #word, [[links]] and ![[embeds]] are literal text: HTML tags (an attribute value like color: #fff is not a tag) and comments, and inline/display math ($a #b$). Math follows the pandoc rules so prose like "$5 and #tag later $6" is not swallowed: the opening $ is followed by a non-space, the closing one preceded by a non-space and not followed by a digit.

MATH_SPAN_PATTERN = /\$\$.+?\$\$|(?<![\\$])\$[^\s$](?:[^$\n]*?[^\s$\\])?\$(?![\d$])/
OBSIDIAN_TAG_PATTERN = /(?:^|(?<=\s))#([a-zA-Z][\w\-\/]*)/

Obsidian tag pattern: #tag (but not inside code blocks, headings, or as a URL fragment like path/#section). Requires the # to sit at start-of-line or after whitespace — this matches Obsidian's own tag-detection heuristic and avoids treating URL anchors as tags.

WIKILINK_PATTERN = /\[\[([^\]|]+?)\\?(?:\|([^\]]+?))?\]\]/

Obsidian wiki-link pattern: [[Page Name]] or [[Page Name|Display Text]]. Inside a table Obsidian requires the alias pipe escaped ([[Page\|Text]]); the backslash belongs to the pipe, not the name.

Instance methods

run(options : Config::Options::ImportOptions) : ImportResult
Source