8000 Support angle bracket escaped markdown urls by CharlesSchimmel · Pull Request #1211 · vimwiki/vimwiki · GitHub
[go: up one dir, main page]

Skip to content

Conversation

CharlesSchimmel
Copy link
Contributor
@CharlesSchimmel CharlesSchimmel commented Feb 16, 2022

Very small change to support Markdown links with angle bracket escaped URIs, like [link title](<path/to/some file>) to enable link-following of angle bracket escaped markdown links. This syntax is part of the the Commonmark spec:

The [link] destination can only contain spaces if it is enclosed in pointy brackets

This is also helpful is people use Obsidian alongside their Vimwiki as Obsidian strongly conforms to markdown standards and will not parse links with enescaped spaces. I believe this is all needed to support link following and concealment/preview.

  • ALL pull requests should be made against the dev branch!
  • Take a look at CONTRIBUTING.MD
  • Reference any related issues.
  • Provide a description of the proposed changes.
  • PRs must pass Vint tests and add new Vader tests as applicable.
  • Make sure to update the documentation in doc/vimwiki.txt if applicable,
    including the Changelog and Contributors sections.

Edited to specifically highlight link-following of angle bracket escaped markdown links and add related commonmark spec

Copy link
Member
@tinmarino tinmarino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please copy-paste a snippet of what you see before and after the changes.
Also note the hardcoded regex because this may break some user configuration.
A link to that markdown spec in comment would be nice (easier to verify).

That said, the improvement seems nice, thank you for the effort. With small changes to get it safe, sure it will be accetpted.

let valid_chars_url = '[^[:cntrl:]]'

let mkd_syntax.rxWeblink1Prefix = vimwiki#u#escape(mkd_syntax.rxWeblink1Prefix)
let mkd_syntax.rxWeblink1Separator = vimwiki#u#escape(mkd_syntax.rxWeblink1Separator)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is hardcoded => bad
Please better change the default data in vars.vim

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would something like let mkd_syntax.rxWeblink1Separator = vimwiki#u#escape(mkd_syntax.rxWeblink1Separator).'<\=' be preferable or should I pull this into a new variable entirely? I'm not sure how to escape it without ruining the \=

@CharlesSchimmel
Copy link
Contributor Author

Visually there will be no change, markdown-style links will be concealed the same way. I should have mentioned that this allows vimwiki#base#follow_link() to work with angle bracket escaped markdown links without trying to include the angle brackets in the file name (navigating to foo in [foo](<foo>) instead of trying to navigate to <foo>).

Commonmark:

The destination can only contain spaces if it is enclosed in pointy brackets

Pandoc doesn't mention it in the docs but it's in the code if that helps.

Thanks! I will fix up the regex shortly.

@hulufei
Copy link
hulufei commented Sep 18, 2023

@CharlesSchimmel @tinmarino this is exactly what I want. Anything I can help with? I'd like to get this PR merged.

@zaldih
Copy link
zaldih commented Sep 24, 2023

I was coming to check if just this feat had been discussed before to work on it and make a PR. I'm glad to see that someone has already worked on it.

I would like to see this PR merge!

@tinmarino
Copy link
Member

Rebased with squashed <= It works fine actually

I am really sorry for the delay, got confused => Was waiting for @CharlesSchimmel who was actually waiting for my answer. Sorry guys.

And well thank you very much @CharlesSchimmel for the PR (and the patience). I hope to see you in another PR 😃

@tinmarino tinmarino closed this Oct 31, 2023
@tinmarino tinmarino reopened this Oct 31, 2023
@tinmarino tinmarino merged commit 0bb1b49 into vimwiki:dev Oct 31, 2023
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.

4 participants
0