Highlighting Text Fragments When Linking

A lot of you awesome folks link to documentation when helping users with issues.

I recently learned a trick from Michael Tsai’s blog.

If you add to the link #:~:text= and then the text (with URL encoding, obviously, so spaces turned to + and other fancy characters percent encoded) then it will highlight the desired text. For example:

https://wiki.keyboardmaestro.com/Functions#:~:text=ROUND

7 Likes

It's an interesting option (and fodder for a macro, I am sure!), but how difficult is ⌘-F? :wink:

Further thoughts:

  • The trick can only help for the first occurrence of the target text.
  • I wonder whether any Wiki page for which this trick is useful is perhaps too long.
  • This trick works with pages in this forum, and I think that could be useful.
1 Like

It does make it easier to draw attention to parts of the documentation:

"Application token returning weird process names and not just the ones you see in the Finder? Use the Foreground parameter."

1 Like

As an alternative solution for linking to the wiki, consider pure Markdown syntax with the wiki's highlighting capabilities:

"Application token returning weird process names and not just the ones you see in the Finder? Use the Foreground parameter."

The relevant text is highlighted here, and when you click the link, all matches are highlighted on the wiki. The structure of the Markdown:

[<mark>Foreground</mark>](https://wiki.keyboardmaestro.com/token/Application_Tokens?s[]=foreground)

This would be trivial to add to many of the existing Markdown link creators as an optional feature.

-rob.

1 Like

This is great. Chrome has a native right-click option to make a link to highlighted texted but Safari does not. So, I was opening Chrome just to do that. With this trick and a Macro to implement it, I can now make the link while staying in Safari. Thanks for sharing @peternlewis

2 Likes

See also:

2 Likes

Or maybe just a new macro, dedicated to posting links from the KM wiki. Something like this...

Download Macro(s): Wiki link maker.kmmacros (34 KB)

Macro screenshot

Macro notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System information
  • macOS 14.7
  • Keyboard Maestro v11.0.3

Select some text on a KM wiki page, press Control-F, and get a highlighted link on the clipboard, ready for pasting. Don't want it highlighted? Press Control-Option-F.

Perhaps useful as a starting point for something else.

-rob.

3 Likes

Actually, the parameter has additional facilities to specify the (unmarked) prefix and postfix so it is usually possible to highlight more specific locations.

2 Likes

Ah, that's interesting. I have found that as I'm selecting sentences and paragraphs there hasn't been a problem with highlighting the wrong text.

Also, in that same article you linked to it mentions that highlighted text links are coming to Safari as a native feature. Using the hint you shared to link to that :grinning:

1 Like