SublimeText-Markdown / MarkdownEditing

Powerful Markdown package for Sublime Text with better syntax understanding and good color schemes.
MIT License
3.17k stars 649 forks source link

Support implicit and shortcut reference links #709

Open reagle opened 1 year ago

reagle commented 1 year ago

F12 allows me to bounce between the first link and its reference, but not the latter two:

According to <https://pandoc.org/MANUAL.html#reference-links>:

[My first link][first] is explicit, 
my [second link][] is implicit,
my [third link] is a shortcut.

[first]: /bar/baz
[second link]: /baz/bar
[third link]: /foo/bar
reagle commented 1 year ago

An aside: once I hit F12, how do I get back to the link? Is the a shortcut to bounce back?

deathaxe commented 1 year ago

Basically bounce should move caret between reference and definition in both directions. I am not too familiar with current implementation though.

My goal would be to make it behave more like normal Goto Definition and Goto Reference somehow and maybe rely on syntax rather than trying to reparse document using regexp patterns.

reagle commented 1 year ago

On the aside: There's no bounce, it's f12 and shift+f12, and I had a keyboard collision from BetterBookmarks messing it up. I sorted that part out.

On the substantive issue, I'm afraid I don't know anything about the implementation (e.g., regex vs syntax AST). Would still love to see implicit and shortcut references though. :)

deathaxe commented 1 year ago

Sure. I need to come up with a plugin, which searches all sorts of links using ST's find_by_scope API. The current solution uses plain regex, which basically duplicates, what syntax definitions have already done.

TBH, I want to finalize some library stuff for Package Control 4.x first as it seems more important to me.