diff --git a/motions/jumpToLink.ts b/motions/jumpToLink.ts index ef44689..a95e06b 100644 --- a/motions/jumpToLink.ts +++ b/motions/jumpToLink.ts @@ -4,44 +4,43 @@ import { MotionFn } from "../utils/vimApi"; /** Regex for a wikilink. Starts off with a negative lookbehind for a backslash, to make sure the * opening square bracket isn't escaped. * - * We don't bother making the internals of the wikilink regex too complicated (using `.*?` to allow - * any characters), because Obsidian's markdown parser is imperfect and inconsistent anyway, so we - * may as well just match anything that generally looks like a wikilink. + * Note that although Obsidian doesn't allow most special characters inside a file name (e.g. `[`, + * `]`, `:`, `#`, `|`, `^`, `\`, or `/`), its Markdown parser is lenient enough to result in + * basically anything inside non-escaped double square brackets being rendered as a wikilink. This + * even includes a trailing backslash, which you'd think would escape the first closing square + * bracket! So we follow suit and allow any character inside the double square brackets, except for + * a newline (which `.` won't match as long as we don't use the `s` flag). */ const WIKILINK_REGEX = /(?