Automatically converting keys to links

I’m trying to find a way to automatically convert specific words into links.

I often insert ticket keys (i.e. PROJ-1234) into my Obsidian notes. I wanted to know if it is possible to have an automation of sort that would find these keys and automatically turn them into links.

The logic is relatively predictable I think since the keys always have the same start and structure and all the automation/macro would have to do is:

  1. Check if the instance of the key is already a hyperlink (in that case ignore)
  2. Convert the key i.e. PROJ-1234 into a link: `PROJ-1234.

Is something like this possible?

I also suffer from the curse of jira, and need to enter ticket numbers in my notes - especially my daily notes, where I track what I need to work on each day.

I wrote a macro where, in the work vault, when I type [ABC-123], it will immediately type (https://xxx.atlassian.net/browse/ABC-123) afterward, turning it into a link. I require typing the brackets because there are times I don’t want it converting ticket numbers to links, and because the brackets will need to end up there anyway, to make it a Markdown link.

Here’s a copy (with identifying information about $DAYJOB removed). You can’t really see it in the picture, but the “title contains” value is “SPACE DASH SPACE vaultname SPACE DASH SPACE”.

Maybe you’ll find this useful, and/or use it as an example of how to build your own macro.

How do you execute that macro? And how do it detect when you’re in an editing mode or not? And how do you prevent it from replacing again and again?

I just type [ABC-123].

Keyboard Masetro monitors your keystrokes. When it sees that you’ve just typed something that matches the “trigger” on an active macro. it runs that macro.

It doesn’t know about “editing mode”. If I were to type that sequence of characters while the keyboard focus is not in an edit-able control …

  • nothing would happen, because keyboard input is being ignored
  • Keyboard Maestro would send its keystrokes, and those would also be ignored

At first I was using a macro that was triggered when I hit “⌃⌥⌘J”, which would type just the https://xxx.atlassian.net/browse/ part, and I would end up having to re-type the ticket number. Your question last night made me think about it again, and I figured out how to do a regular expression match against whatever typing had triggered the macro (to extract the ticket number), then use that as part of what Keyboard Maestro types for me.

1 Like