Skip to content

obsidian-word-characters

How Obsidian decides where a name may match as an unlinked mention, restated so the index can find the same matches without running a regular expression per name over every note.

Obsidian 1.14.4 builds one RegExp(source, 'gi') per name of the target note. A name whose first character is a WORD character must be preceded by a non-word character or the start of the file, and one whose last character is a word character must not be followed by one. The word characters are a fixed table of Unicode letters and digits, copied below. This is not a Unicode letter classification: for example, a name such as 東京 has no word character at all and matches inside any run of text. There is no u flag, so case is folded the way a non-Unicode i regex folds it, one UTF-16 code unit at a time, and diacritics are not folded at all.

Function Description
canonicalizeObsidianText Canonicalizes text for Obsidian Search and unlinked mentions’ non-Unicode ignore-case regex matching. Preserves UTF-16 length, lone surrogates and accents. This is not Unicode or locale case folding: Greek final sigma folds to sigma’s uppercase, but Kelvin sign, long s and dotless i do not fold to ASCII. Verified against core Search’s gmi expressions in Obsidian 1.14.5 and 1.15.0.
createObsidianMentionRegExp Builds the regular expression Obsidian matches a name with, one per name, exactly as its own recomputeUnlinked builds it. Group 1 is the name itself.
getObsidianNameTokens Splits a name into the canonical word tokens the index keys it by.
isObsidianWordCharacter Whether a UTF-16 code unit is one of Obsidian’s word characters.
tokenizeObsidianWords Splits text into its maximal runs of word characters, each folded to its canonical case. Every match Obsidian finds for an indexable name covers whole runs of this split, in order and with nothing between them, which is what lets the index find candidates without the regular expression.