Skip to content

Add wiki link escaping #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

stephankoe
Copy link

The changes in this pull request modify the wiki link patterns to skip escaped wiki links. Consistent with Obsidian, wiki links can be escaped with a single backslash \ character before the first opening bracket, e.g., \[[escaped]]. If the opening bracket is preceded by two backslashes, it is not escaped, e.g., \\[[not escaped]].

This pull request resolves the following issue:

Note For now, there is no way to escape obsidian wiki links. Every link will be replaced with a hugo link.

The following regex is added to the wiki link regex: (?:^|(?<=[^\\])|(?<=\\\\))\[\[(.*?)\]\].

  • \[\[(.*?)\]\]: Wiki link pattern, two opening square brackets, followed by an arbitrary character sequence, end ended by the next two closing square brackets.
  • (?:^|(?<=[^\\])|(?<=\\\\)): Specifies that to be a valid wiki link, the first opening bracket must be preceded by:
    1. the start of the sequence ^,
    2. any character that is not backslash, or
    3. two backslashes.

@stephankoe stephankoe changed the title Wiki link escaping Add wiki link escaping Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant