MACRO: Markdown Link Tool, v5.0

HTML <a> tags ought to work in Markdown. So you could continue to use them.

I say that as a big fan of Markdown.

I wouldn't want to maintain a document that someone had written in HTML. I do maintain documents collaboratively written with others in Markdown. (Not least presentations written in it and put through mdpre/md2pptx.)

Martin:

I don't write with others, I don't maintain documents written by others, and I have zero interest or need to use Markdown. My HTML writing is directly in blog posts, for web pages, or for KM macros, and I'm 100% comfortable using HTML in those situations.

For me, it makes no sense to work with a subset of the entire language, in a different dialect as it were, when I can just use the language itself. I know that's not true of others, and I know many rely on Markdown to make it much easier to work on shared documents with people who don't know HTML. None of that applies to me, though.

-rob.

1 Like

@_jims I just came across this and at first thought I wouldn’t have any use for it. I was wrong!

I just downloaded it and immediately saw its utility. I made one adjustment that makes it a little easier to use this on multiple computers. I have the variables populated from text files saved in my Dropbox that way I don't have to worry about updating the variables in KM Editor on each device. This way I can just edit the text files when I want to make updates to my list.

Thanks again for sharing!

Hi @cdthomer. Glad you find it useful.

So far, I've been using it primarily when participating on forums—and lately this has been my favorite one. :grinning:

if you are doing the same, you might also find this macro useful: Augment or Filter Text

Nice enhancement—thanks for sharing! I'll likely make a similar change on my personal copy (I'll use iCloud Drive, however), but as you likely know, a feature that includes interaction with the file system introduces some implementation friction for newcomers, particularly when Dropbox is introduced. On the other hand, pros like you can easily make an enhancement like you have shared.

With that said, I'll give this some more thought. Maybe I could make it an option to use files.

Thanks again, for sharing your feedback.

If you haven't done it already, you could modify the Edit Me logic to open the folder that contains these files.

On this particular detail, you might want to check out Log It. With that macro, there's an option to open and enclosing folder or a specific file. The revised Edit Me could open the folder or optionally open the file associated with the MarkdownLinks User variable.


Responding to feedback by @cdthomer, I've updated Markdown Link Tool to Version 3.0.

  • Moved Markdown Links from text variables to configuration files: 0 Favorites.md; 8 Keyboard Maestro Forum.md; 9 Keyboard Maestro.md. Other md files can be optionally added to the same folder. Added options to: 1) navigate to the configuration folder, 2) open the configuration files, 3) Prepend to or Append to a Markdown Link in the clipboard to the configuration files.

  • Changed the primary trigger from ⌥⇧L to ⌥⇧M. Added a secondary trigger (⌃⌥⇧M) to provide direct access to the configuration files.

1 Like

This is great Jim, I have really come to like this macro and it has become one of my most frequently used ones throughout my day.

Question: when I made those modifications to my personal copy I saved the files as txt files, what are the advantages to using md files?

EDIT: a followup! I made a slight modification to this portion of the macro to automatically populate the Text field with the front window's name... because I am that lazy :laughing:

1 Like

Thanks, @cdthomer. I appreciate the feedback. Glad you find this macro useful.

Many text editors (e.g., BBEdit) will apply proper Markdown syntax coloring/highlighting for files with an md extension.

That's a great idea, but when testing with Safari, I've noticed an issue. If I go to the search/URL bar (using File > Open Location—⌘L), then Copy—⌘C, and run the macro %WindowName%1% is empty (at least, most of the time). However, if I click onto the body of the web page after ⌘C and run then macro, %WindowName%1% includes the web page title. I do not see this same issue with Chrome.

After discovering this issue, I replaced %WindowName%1% with %SafariTitle% and that seems to be populated as expected. So my questions to you, @cdthomer :

  • Did you add %WindowName%1% to get a web page title?
  • If yes, what browser have you been using?

Based on you suggestion and my testing, here's what I'm thinking of adding to the next version:

Proposed modification-image

Keyboard Maestro Export


Also, as I was working through this, if the URL is empty and Safari or Chrome is running, I was thinking, why not I prompt to populate with one, the other, or both of the following:

  • [%SafariTitle%][%SafariURL%]
  • [%ChromeTitle%][%ChromeURL%]

So considering your feedback and this addition, here's how the whole section would change:

Macro section-image

Whew, that's a lot of work to get one Markdown link!

After I hear back from you, @cdthomer, I'll share an updated version of the macro.

Hey Jim, yes I used %WindowName%1% to get the title, and I noticed the same issue on occasion.
I use Safari only.

I like the changes you proposed! I’ll keep an eye out for the update!

@cdthomer, thanks for the quick reply.

I've been continuing to test since my previous post. Even though it seems to work, it can be slow under some circumstances and I'm not keen on the complexity that it adds.

Here's an alternative approach that I'm strongly considering for the next version:

Alternative approach-image

1 Like

Hello @_jims, How are you creating these nice GIF demos? I'm using free LiceCAP, but it doesn't show the keyboard shortcuts ...

1 Like

I’m curious too how he’s able to screen record the entire screen and not have the file be so large that it can’t be uploaded :sweat_smile:

Hi @ALYB and @cdthomer. Great questions. I wish I had a nice, simple, and fast process I could share, but unfortunately I don't.

Before I get into the specifics, allow me to step back. With macros here (and with iOS shortcuts elsewhere) I've supplemented my forum posts in three ways:

  1. Screenshots

  2. Screencasts uploaded to YouTube and referenced in a post. Some forums allow YouTube embedding, others don't. I can't remember if I've tried embedding on this forum. But I have included links to YouTube videos. Here are two that immediately come to mind:

    a. Log It—Quickly Save Plain Text Snippets to One or More Log Files : youtu.be/Zp-8BHhxPLY

    b. Augment or Filter Text : https://youtu.be/Yvnwopo6fio

  3. GIF Animations (like above)

As I'm sure you know, screenshots are simple and fast. I'm a Setapp subscriber so I use CleanShot X. When I worked at a F50 company and was forced to use Windows, I used Snagit. There is a version of Snagit for macOS, but I've never tried it.

Also, as I'm sure you know, for screencasts and GIF Animations, the time and effort is a huge step change up. For a few of my macro (and iOS shortcuts) posts, I've spent more time on the screencast than on the macro/shortcut. :frowning:

When I do decide to use a screencast or GIF animation, I start with ScreenFlow. I do some independent consulting and purchased it for that work, so I've been able to absorb the $150 initial cost and $50 upgrade fees.

ScreenFlow is okay, but I'm not a huge fan. It does, however, have a Show Keystrokes feature with two options: 1) Show all keys, 2) Show only modifier keys.

I've found that the Show Keystrokes feature is far from flawless: more than once I've had to repeat a recording session. Also, since keys are never pressed exactly simultaneously, combinations like ⌃⌘C are normally recorded on the timeline in a sequence something like this:

 ⌃ ... ⌃⌘ ... ⌃⌘ ... ⌃⌘C ... ⌃⌘C ... ⌃⌘C ... ⌃⌘C ... ⌃⌘ ... ⌃⌘ ... ⌘ 

Since all sequences except ⌃⌘C are distracting within screencast, I split the recording into clips and selectively disable Show Keystrokes for the clips that include the subsets of the ⌃⌘C. (I hope that makes sense.) This process is tedious and IMO the Show Keystrokes feature has some room for improvement (e.g., maybe time thresholds could be added to avoid the key combination subsets).

I've converted some of my shorter MP4 recordings to GIF animations using gifski. To keep the final GIFs small I reduce the frame rate (to a value that still looks decent), but the biggest factor seems to be the recording dimensions. For the GIF above, I set my 16" MBPro to 1152x720 before starting the ScreeFlow recording session.

I hope that helps. This topic probably merits a separate thread as I'm sure others have more insight than me. I'd certainly love to learn about a process that is simpler.

2 Likes


After discussions with @cdthomer, I've updated Markdown Link Tool.

Version 3.2

When potentially updating a configuration file with the Clipboard contents, if a Markdown Link is not found, this macro executes the macro Copy as Markdown Link. This macro can build a Markdown Link to browser pages and elements for many other applications.

1 Like

I've updated the OP with Version 3.3 of Markdown Link Tool:

  • Added several new markdown links to the configuration files. This macro now includes 150+ links.
  • Corrected a few typographical errors within comments and one within a dialog.
  • Updated the information in TESTED WITH.
2 Likes

Hello @_jims @ComplexPoint @cdthomer,

I am very grateful for this macro which I use a lot. I am working on a mind map using Simple Mind.

When I try to copy the markdown link, I see the error message below. How could I write a macro to add simple mind to the library of markdown list macros ?

Thanks very much!

2 Likes

I don't use SimpleMind myself, but looking at the Trial version, I see that its menu paths include:

Edit > Link Topic > Copy Link to Topic

Does that seem to work ? Here, I may have misread its function, or there may be a limitation imposed on the trial.

If that menu path does, in fact, capture a url for a selected node, then you can get the label for a node with a simple Edit > Copy and assemble a submacro, using successive clipboard contents, along the lines of others in:

RobTrew/copy-as-md-link: macOS Keyboard Maestro macro group

but with:

  • the name com.modelmakertools.simplemindosx
  • and code which:
    • just assigns a value to the KM variable mdLink
      (in the form of a [label](url) string)
    • assembled by script or KM blocks in the manner that you will see in other sub-macros in the copy-as-md-link group.

It's not clear to me, however, (after a cursory search) whether SimpleMind actually supports its own url-scheme, and it also looks as if there may be some sandboxing limitations on link-navigation if you have the AppStore version.

See the asterisked footnote at the bottom of:

Navigation link (to a file, topic, contact or the web) - SimpleMind

https://simplemind.eu/faq/navigation-link/

2 Likes

OK. All clear. thanks very much !

I've updated the OP with Version 4.0 of Markdown Link Tool:

  • When 𝗠𝗮𝗻𝗮𝗴𝗲 𝗟𝗶𝗻𝗸𝘀 is selected, if the clipboard contains a URL, a dialog will appear that provides an option to create and save a Markdown link. See the HOT KEY TRIGGER section above for more information.

  • When managing links, added a dialog option to skip the addition of a new link.

  • When markdown links are prepended, they are now placed below the comments at the beginning of the text files. Now using the native Write To File action, thus if KM v8.1+, the previous version of the text file will be moved to the Trash.

  • If using KM v10.2+, when markdown links are appended, using the native Append Text To File since the read-only issue has been addressed. See the comments below for more information. Also, since this native action is being used, the previous version of the text file will be moved to the Trash.

  • If using KM v10.2+, removed the Prompt With List default value (all:).

  • Fixed bugs related to the HTML, Bracketed URL, or Plain URL formats.

  • Moved the Clipboard restoration logic and CancelJustThisMacro to a single location.

  • Added several new markdown links to the configuration files. This macro now includes 160+ links.

  • Updated the information in TESTED WITH.

4 Likes

I've updated the OP with Version 4.1 of Markdown Link Tool:

  • Clipboard restoration is now properly handled when the Clipboard is initially empty.

  • Deleted a few duplicate entries in 0 Favorites.md, 8 Keyboard Maestro Forum.md, and 9 Keyboard Maestro.md.

I've updated the OP with Version 5.0 of Markdown Link Tool:

  • In the link management section of the macro, if the Clipboard includes a URL two dialog options were added: Skip and Clear CB and Skip. When either option is selected, the macro continues and spawns Copy as Markdown Link, a macro by @ComplexPoint to potentially create a Markdown Link from the current application context. Previous versions only included two options: OK (to process the Clipboard URL) and Skip (to open the link files folder). In this version, the previous Skip button has been changed to Folder.

  • Improved error checking and more information to the dialogs that appear during analysis of URLs/Markdown Links found in the Clipboard or created by Copy as Markdown Link.

  • Improved the readability of the main Prompt With Lists by adding :point_right:t6: to the entries that contain information regarding alternative actions that can be summoned using modifier keys.

  • Improved readability of the Prompt With List used to select the mode for updating links files.

  • the CSS Style generation, by moving style comments to a Comment action above local_Style.

  • Changed from AppleScript to Set Variable to Text to delete the global variables used in the JXA that creates the two-variant clipboard.

  • Changed the settings to use local variables. Previously global variables were used and the values were then copied to local variables. (This seemed like a good idea, but it really added unnecessary complication.)

  • Streamlined some of the macro logic.

  • Added several new markdown links to the configuration files. This macro now includes 175+ links.

  • Updated the information in TESTED WITH.


By default, this macro includes 175+ Markdown links segregated into three text files:

  • 0 Favorites.md

  • 8 Keyboard Maestro Forum.md

  • 9 Keyboard Maestro.md.

The integer prefix is included to set the order that the links are presented. The text files are stored in a folder defined within the macro. Text files can be added, deleted, and, of course modified.

The macro begins by displaying the list of stored Markdown Links...

The top entry in the above list is informational:

:point_right:t6: Selected link will be 𝗣𝗮𝘀𝘁𝗲𝗱 -or- ⇧:𝗢𝗽𝗲𝗻; ⌥:𝗖𝗹𝗶𝗽𝗯𝗼𝗮𝗿𝗱; ⌥⇧:𝗔𝗹𝘁𝗲𝗿𝗻𝗮𝘁𝗲 𝗙𝗼𝗿𝗺; ⌃⇧:𝗠𝗮𝗻𝗮𝗴𝗲 𝗟𝗶𝗻𝗸𝘀


Markdown Links in the Clipboard or from the current application context* can be added two ways:

  1. From the above list ⌃⇧:𝗠𝗮𝗻𝗮𝗴𝗲 𝗟𝗶𝗻𝗸𝘀 is selected, i.e., ⌃⇧ are down when return is pressed.
  2. The macro is launched with a trigger that includes the Control key (⌃).

* This feature is provided by spawning the excellent macro Copy as Markdown Link by @ComplexPoint.


New Markdown Links can be added in a variety of ways using the options in this list.

Typically I'll append links to one of the three files and later come back with a text editor and move the links into a section that is appropriate.


If the first item in the above list is selected, the folder that contains the links will be opened in the Finder. Note that I have chosen to store my links in an iCloud Drive folder. Any files in this folder that include an md extension will be used by this macro.

2 Likes