Shorten URLs in hyperlinks



Typically URLs are very long. Is there any way to suppress them into an icon, like [a link](:tickets:) instead of [a link](https://a_very_long_url/here/just_an_example)? This feature will save a lot of space and distraction. Thanks.

(Takuya Matsuyama) #2


Thank you for the suggestion.
I think it’d be nice to be a plugin.
I had a brief research for this and found a way to accomplish.

CodeMirror has TextMarker API which allows you to mark a range of text with a specific CSS class and to replace with a specific DOM element.
For example, you can do like so:

// Get the Editor
var cm = inkdrop.getActiveEditor().codeMirror
// Create an element
var el = document.createElement('span')
el.innerText = 'πŸ”—'
// Create a mark
let marker = cm.markText({line: 2, ch: 42}, {line: 2, ch: 85}, { atomic: 1, replacedWith: el, clearOnEnter: true })

And it will look like just as you expect:

As clearOnEnter is enabled in the options, the mark will be cleared when the cursor enters its range so you can edit the URL.

Since I’d like to focus on core features, I hope you or other people will make it as a plugin.