Skip to content

Pipe syntax for outgoing links#125

Draft
Nicendredi wants to merge 2 commits intobingryan:masterfrom
Nicendredi:pipe-syntax-for-outgoing-links
Draft

Pipe syntax for outgoing links#125
Nicendredi wants to merge 2 commits intobingryan:masterfrom
Nicendredi:pipe-syntax-for-outgoing-links

Conversation

@Nicendredi
Copy link

@Nicendredi Nicendredi commented Mar 2, 2026

Captures the alias of Obsidian links if it exists. e.g.:
[[My note|A special note]] becomes A special note, if removeOutgoingLinkBrackets is activated.

Tested locally on my Obsidian vault with a note containing the following types of links :

  • [[My note]] -> My note
  • [[My note|A special note]] -> A special note
  • [A special note](../folder/My%20note.md) -> [A special note](../folder/My%20note.md)

As seen in the example, there is still a problem with Markdown-style links in the original note. The rule to handle this edge case will be quite complicated to implement, if you want links to external URLs to be correctly exported, but links to Obsidian Vault files to be handled in the same way as the first two link styles.

Proposed solutions for the last edge case :

  • add "does not handle markdown-style links" in the description of the option "Remove brackets for outgoing links"
  • edit the regex to also handle markdown-style links

Captures the alias of Obsidian links if it exists. e.g.:
[[My note|A special note]] becomes A special note, if removeOutgoingLinkBrackets is activated.
@coderabbitai
Copy link

coderabbitai bot commented Mar 2, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)

✅ Unit Test PR creation complete.

  • Create PR with unit tests
  • Commit unit tests in branch pipe-syntax-for-outgoing-links
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Nicendredi
Copy link
Author

Fixes #124 created as a draft until last edge case solution chosen

@Nicendredi
Copy link
Author

Nicendredi commented Mar 2, 2026

I've tested a new regex that will handle all three cases :
/(?<!!)\[\[(?:[^|\]]*\|)?(?<alias>[^\]]+)\]\]|\[(?<alt>[^\]]*)\]\((?<url>[^)]+)\)/g

If we change the replaceAll to be :
replaceAll(OUTGOING_LINK_REGEXP, (_match: string, alias: string, alt: string, url: string) => alias || alt || url)
then we get :

  • [[My note]] -> My note
  • [[My note|A special note]] -> A special note
  • [A special note](../folder/My%20note.md) -> A special note
  • [](../folder/My%20note.md) -> ../folder/My%20note.md

If the last case above is not what you want, we just need to remove the || url from the lambda function result. In that case, the link will be remove instead of being replaced, but only for that strange edge case.

@bingryan
Copy link
Owner

@Nicendredi ready for review ?

@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request

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.

2 participants