Initial Prompt With List to Select a Markdown Link
Selected Markdown Link – Optional Reformat
Selected Markdown Link – Optional Change of Link Text
Adding Markdown Links (1 of 2)
Adding Markdown Links (2 of 2)
Installation Instructions
-
Download and unzip the following file.
-
Install and activate the included macro.
-
Move the three text files (with the md extension) to the folder specified in the variable local_Folder.
Markdown Link Tool-v7.0.zip (40.3 KB)
Documentation
PURPOSE
This macro will paste a markdown link selected from a managed list. This provides an efficient method to enter links on multiple platforms. For example:
✓ Email (rich text)
✓ Word Processors (rich text)
✓ Keyboard Maestro macro comments (rich text)
✓ Apple Notes (rich text)
✓ forum posts (plain text)
✓ text editors (plain text)
If the currently selected object can render rich text, the link will be entered as Rich Text; otherwise, Plain Text. In these cases the System Clipboard will not be affected.
Optionally, before pasting the markdown link, it can be reformatted into three other forms:
• HTML
• Bracketed URL
• Plain URL
Also the link Text can be changed before pasting.
The markdown link, or other forms, can be alternatively written to the Clipboard* rather than pasted into the currently selected platform. Also alternatively, the URL associated with selected markdown link can be opened in the default browser.
Lastly, this macro includes options to add to and modify the configured list of markdown links. These links reside in one or more text files in a configured folder. See SETTINGS for more information.
*When the Clipboard option is selected, the macro will populate the System Clipboard with both variants/flavors, Rich Text and Plain Text. The Clipboard can subsequently be pasted based on the context of the selected platform object.
MANAGEMENT OF MARKDOWN LINKS
This macro comes supplied with more than 240 Markdown Links—mostly related to the Keyboard Maestro application and the forum. However, links for any context can be easily deleted (individually or as a group) and others can be quickly added as well.
The markdown links are stored in text files (with an md extension) that reside in a specified folder. Although the folder can contain as any number of md files, three are supplied with the macro download:
0 Favorites.md : Some miscellaneous and recent posts and macros from the forum, and some macros that I have contributed. These are provided as examples—modify this, or any of the other files, as needed.
8 Keyboard Maestro Forum.md : Macros that appear in the following forum post: Best Macro List—Macro Library. This was a curated list maintained by @JMichaelTX, who unfortunately is no longer with us. I’m not sure if this forum list will be maintained moving forward. I've added some of my personal favorites to this file.
9 Keyboard Maestro.md : Helpful links from the Keyboard Maestro Forum and the Keyboard Maestro Wiki.
To exclude the Markdown Links in any of these files: 1) rename the file by changing the extension from md to txt., or 2) delete the file.
A text editor can be used at anytime to modify the md files. The macro Copy as Markdown Link by @ComplexPoint is a great tool that can be used to populate the md files.
If the macro is triggered with the secondary hot key, the one that includes the Control key (⌃), then the macro will present options to manage the links in the configuration files. This process will be referred to as Manage Links. During normal operation, the macro will present an option to Manage Links from the initial and link form Prompt With Lists.
If Manage Links is selected (or initiated by the secondary trigger), the following will occur:
-
The System Clipboard will be checked for a markdown link. If one is found, there will be an option to save it.
-
If installed, the macro Copy as Markdown Link by @ComplexPoint will be spawned. That macro will attempt to create a markdown link based on the focused object within the active application. If a link is successfully created, there will be an option to save it.
-
The markdown link from Step 1 or 2 can be prepended or appended to any of the configuration text files. Alternatively, any of the files can be edited and the link can be pasted into any file position.
-
The folder enclosing the configuration files can be opened.
READ THE DETAILS HERE (OR JUST TRY IT OUT)
When this macro begins, the list of links will be displayed by a Prompt With List action. The first two lines, which are not selectable but serves as a guide, will be:
Selected link will be 𝗣𝗮𝘀𝘁𝗲𝗱 -or- ⇧:𝗢𝗽𝗲𝗻; ⌥:𝗖𝗹𝗶𝗽𝗯𝗼𝗮𝗿𝗱; ⌥⇧:𝗔𝗹𝘁𝗲𝗿𝗻𝗮𝘁𝗲 𝗙𝗼𝗿𝗺
⌃⇧+any item click:𝗠𝗮𝗻𝗮𝗴𝗲 𝗟𝗶𝗻𝗸𝘀
Thus if a link is selected and…
• No modifiers are down, the link will be pasted (assuming the focus is on an object that can accept text).
• Shift is down, the URL will be opened in the default browser.
• Option is down, the Markdown Link will be written to the System Clipboard (as Rich Text and Plain Text).
• Option+Shift are down, the macro will present a second Prompt With List with alternate forms of the link (HTML, Markdown, Bracketed URL, Plain URL) for selection.
• Control+Shift are down, the macro will present options to manage the links in the configuration files*.
When the list of forms (HTML, Markdown, Bracketed URL, Plain URL) is rendered by the second Prompt With List action, the first two lines, also serving as a guide, will be:
Selected form of the link will be 𝗣𝗮𝘀𝘁𝗲𝗱 -or- ⇧:𝗢𝗽𝗲𝗻; ⌥:𝗖𝗹𝗶𝗽𝗯𝗼𝗮𝗿𝗱; ⌥⇧:𝗖𝗵𝗮𝗻𝗴𝗲 𝗟𝗶𝗻𝗸 𝗧𝗲𝘅𝘁
⌃⇧+any item click:𝗠𝗮𝗻𝗮𝗴𝗲 𝗟𝗶𝗻𝗸𝘀
If a link form is selected and…
• No modifiers are down, the link in the selected form will be pasted (assuming the focus is on an object that can accept text).
• Shift is down, the URL will be opened in the default browser.
• Option is down, the link in the selected form will be written to the System Clipboard (as Rich Text and Plain Text).
• Option+Shift are down (and HTML or Markdown are selected), the macro will present a dialog* that provides an option to change the link Text.
• Control+Shift are down, the macro will present options to manage the links in the configuration files.
*The link Text dialog will also include the following guide information:
The following link will be 𝗽𝗮𝘀𝘁𝗲𝗱.
-- or --
⇧+OK click : 𝗢𝗽𝗲𝗻 𝗨𝗥𝗟
⌥+OK click : 𝗪𝗿𝗶𝘁𝗲 𝗟𝗶𝗻𝗸 𝘁𝗼 𝗖𝗹𝗶𝗽𝗯𝗼𝗮𝗿𝗱
⌃⇧+OK click : 𝗦𝗸𝗶𝗽 𝗮𝗻𝗱 𝗠𝗮𝗻𝗮𝗴𝗲 𝗟𝗶𝗻𝗸𝘀
The alternative options, when the OK button is Clicked*, with modifiers down, are the same as described above.
*When this dialog is displayed, the modifier keys will not be honored if a press is used rather than an OK click. This seems to be a limitation with the Prompt For User Input action.
HOT KEY TRIGGERS
If the trigger includes the Control key (⌃), the macro will skip to the link management section of the macro. See more information, see MANAGEMENT OF MARKDOWN LINKS.
SETTINGS
• local_Folder : Markdown Links for this macro are stored in text files (with md file extensions) in this folder. By default, this is set to an iCloud Drive folder, but it can be changed to any folder that is writable.
• local_FavoritesFile : one md file should be designated as the Favorite File.
ACKNOWLEDGEMENTS
a) The Keyboard Maestro forum post, Using Prompt With List to modify variables on the fly and the macro within, All-in-one URL handler, by @griffman provided the inspiration for this macro! Several ideas from All-in-one URL handler are used here. The primary difference is that All-in-one URL handler does not support Markdown links.
b) @ComplexPoint kindly permitted me to include within this macro a JXA script found in Copy Markdown as Link. This script creates the rich text/plain text combo mentioned in the PURPOSE above.
TESTED WITH
• Keyboard Maestro 11.0.3
• Sequoia 15.2 (24C5079e)/MacBookPro18,2
• Mojave 10.14.16/Macmini6,2
• High Sierra 10.13.6/iMac11,1445
VERSION HISTORY
1.0 - Initial version
2.0
a) When pasting, if the current object selected can render rich text, the link will be entered as Rich Text; otherwise, Plain Text. When the Clipboard option is selected, the macro will populate the Clipboard with both variants, Rich Text and Plain Text. The Clipboard can subsequently be pasted based on the context of any selected object. This context sensitivity, when pasting and with the Clipboard, is thanks to a JXA script provided by @ComplexPoint.
b) Added a few Keyboard Maestro Wiki entries—MarkdownLinks Default 2; added a few more examples—MarkdownLinks User.
c) Made several refinements to dialog text, messages, and macro comments.
2.1
a) Updated parsing of text lists.
b) Other changes to increase macro speed.
3.0
a) 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.
b) Changed the primary trigger from ⌥⇧L to ⌥⇧M. Added a secondary trigger (⌃⌥⇧M) to provide direct access to the configuration files.
3.1 - Updated the information in TESTED WITH.
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.
3.3
a) Added several new markdown links to the configuration files. This macro now includes 150+ links.
b) Corrected a few typographical errors within comments and one within a dialog.
c) Updated the information in TESTED WITH.
4.0
a) 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.
b) When managing links, added a dialog option to skip the addition of a new link.
c) 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.
d) 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.
e) If using KM v10.2+, removed the Prompt With List default value (all:).
f) Fixed bugs related to the HTML, Bracketed URL, or Plain URL formats.
g) Moved the Clipboard restoration logic and CancelJustThisMacro to a single location.
h) Added several new markdown links to the configuration files. This macro now includes 160+ links.
i) Updated the information in TESTED WITH.
4.1
a) Clipboard restoration is now properly handled when the Clipboard is initially empty.
b) Deleted a few duplicate entries in 0 Favorites.md, 8 Keyboard Maestro Forum.md, and 9 Keyboard Maestro.md.
5.0
a) 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.
b) 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.
c) Improved the readability of the main Prompt With Lists by adding to the entries that contain information regarding alternative actions that can be summoned using modifier keys.
d) Improved readability of the Prompt With List used to select the mode for updating links files.
e) Simplified the CSS Style generation, by moving style comments to a Comment action above local_Style.
f) Changed from AppleScript to Set Variable to Text to delete the global variables used in the JXA that creates the two-variant clipboard.
g) 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.)
h) Streamlined some of the macro logic.
i) Added several new markdown links to the configuration files. This macro now includes 175+ links.
j) Updated the information in TESTED WITH.
6.0
a) Keyboard Maestro v11+ is now required.
b) The Markdown Links can now be exported to a JSON file. This is initiated by launching the macro from the Keyboard Maestro editor with the Command Key (⌘) down. The file, MLT.json will be written to the folder defined by local_Folder. I use this exported file to import into the application Anybox. (The JSON is structured to import the links into the MLT Anybox Collection.) With that information in Anybox, on iOS, I created a shortcut named Markdown Link Tool that uses Choose from List shortcut action. The shortcut then updates the iOS Clipboard with the selected Markdown Link.
c) Running Copy Markdown as Link is done using AppleScript. This allows the UUID to be a variable which gives some flexibility. The UUID included by default refers to the 2024-03-16 version downloaded from the GitHub site: GitHub - RobTrew/copy-as-md-link: macOS Keyboard Maestro macro group – single keystroke to copy MD links from different applications
d) Optimized the method to compile and present the saved links, thus the initial Prompt With List appears more quickly.
e) Modified the logic to significantly improve performance.
f) Removed the header comment to conserve space in the Keyboard Maestro plist. The header information is now available only on the Keyboard Maestro forum.
7.0
a) From the first two Prompt With Lists, Manage Links is now done using ⌃⇧+any item double click. Previously ⌃⇧Return was another option. This change was necessitated by macOS Sequoia that uses the Keyboard Shortcut ⌃Return to display contextual menus (and unfortunately ⌃⇧Return does the same). For more information, see 50 New macOS Sequoia Features and Changes Worth Checking Out - MacRumors (#46).
b) Updated two of the three configuration files (0 Favorites.md and 8 Keyboard Maestro Forum.md) with new markdown links: The three included configuration files now include over 240 links.
c) Added a group action (disabled by default) that can be used to report the total number of links.
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 15.2 (24C5079e) PRE-RELEASE SEED SOFTWARE
- Keyboard Maestro v11.0.3