Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Automatically detect URLs in text and make them clickable
<mark>
tags from search queryURL detection
After a quick google search it was obvious that this is not a simple task and I should rely on battle-tested external libraries.
The top 3 npm packages in this regard are:
Autolinker
By far the most used and still maintained, but it has a size footprint of 2MB. Now the whole Virtual Json Viewer plugin, including the compiled JQ binary is 2.3MB. While it's true that the size is not a concern for browser plugin I didn't feel like doubling it just to linkify some urls.
Linkify
Second from the top and reasonable size. I gave it a try, but wasn't satisfied by the results both missing (e.g. no ipv6 links) and spurious (e.g.
_localhost
).Anchorme <- the winner!
The underdog (just like my plugin!). It claims to be extremely fast, it's small and worked well on all input test cases. Even though it seems abandoned I still decided to use it and confine it to an easy-to modify class if the need will ever arise.
Merge search with links
Since both search and links "cut" the text independently, their results must be merged and the tags must be rebalanced.
e.g.
ab(cd)e + a[bc]de = a[b(c)](d)e