Sometimes your code contains URLs to other supporting documentation. It's a nice experience for the reader if those urls were actually links instead of having to copy-paste them.
It's a little thing, but Torchlight sweats the little things so you don't have to.
Using the autolink
annotation, Torchlight will look for URLs and turn them into links for you.
1/**2 * @see https://bit.ly/2UMUsiu. [tl! autolink]3 */45$link = 'https://bit.ly/2UMUsiu' // [tl! autolink]
1/**3 */4
The resulting link will look like this (color will change depending on your theme):
1<a target="_blank"2 rel="noopener"3 class="torchlight-link"4 style="color: #032F62;"5 href="https://bit.ly/2UMUsiu">https://bit.ly/2UMUsiu</a>
(Line breaks added for readability.)
Torchlight adds a torchlight-link
class, and rel
+ target
attributes.
The rel=noopener
attribute ensures that no a malicious website doesn't have access to the window.opener
property. Although this is less of a concern now with modern browsers, we still want you to be covered.
Read more about rel=noopener
at mathiasbynens.github.io/rel-noopener.
Your URL must start with one of the following in order to match:
http:
https:
www.
The autolink annotation supports the entire set of range modifiers to help you quickly annotate a whole set of lines.
Check out the range docs for more details, but here is a quick cheat sheet.
1autolink -- This line only 2 3autolink:start -- The start of an open ended range 4autolink:end -- The end of an open ended range 5 6autolink:10 -- This line, and the 10 following lines 7autolink:-10 -- This line, and the 10 preceding lines 8 9autolink:1,10 -- Start one line down, highlight 10 lines total10autolink:-1,10 -- Start one line up, highlight 10 lines total