Style Text (Markdown/HTML)

Here's my take on text formatting, which you may find useful when writing forum posts or building macros:

This particular macro doesn't deal with lists, tables or other complex formatting. If you need that sort of thing, you're better off with this excellent macro by @_jims.

For a comprehensive guide to text formatting, you may also like to check out another of his posts.

Usage:

Select some text, trigger this macro, choose a style and either click it or hit .

Style Text (Markdown-HTML).kmmacros (59 KB)

Macro screenshot

7 Likes

Cool macro. (used to bold that text ;- )

A couple Keyboard Maestro macro suggestions.

The Copy action does exactly what the Copy and Wait for Clipboard to Change group does.

And Insert Text by Pasting action does exactly what the last two actions (Set System Clipboard to Text (oddly renamed to Set System Clipboard to Style Text) and Paste) do.

It makes no difference of course, you can use multiple actions to do what a single action does with negligible cost.

2 Likes

Hi, @noisneil. Really nice! Thanks for sharing.

Folks using your cool macro might also find this information useful:

Entering and Enhancing Forum Posts


Now for a few suggestions:

  1. If I have text selected and trigger the macro, but then discover that I need to do something else before applying a style, it would be nice if the window could be dismissed two ways: 1) esc, or 2) return (with nothing in the Search formats... field).

  2. Admittedly I'll probably use the search, enter a few characters, and return method mostly, but when using the click method, I'd prefer a single click vs a double click.

  3. When no text is selected and the macro is triggered, IMO it's a bit disconcerting when nothing happens. Consider falling back to the clipboard text. This is really nice when pulling text from one doc for another. If this piques your interest, check out: Get Selected Text, Otherwise Clipboard

  4. Consider adding an option to apply the <kbd> tag to the string as a whole.


Lastly, you mentioned Augment or Transform Text. I do use it often when composing forum posts, but I probably use it more when creating macros. Just an FYI for those that might want to check it out.

Thanks for the suggestion. I added this in haste late last night when I noticed the potential for the macro to continue perpetually if no text has been selected, but forgot that the Copy action has its own timeout (not all actions do). I've updated it now, with an added check to ensure the clipboard contains text.

I know, yeah. This is the result of me considering things I could do with the clipboard other than just paste it. Updated now.

It's a habit of mine to name actions so that I know exactly what they're doing without having to expand them. Moot now that I've removed it.

While I have your attention... In lieu of a solution to the rather aggravating scroll behaviour of extended text boxes, do you think you might be able to implement a search box for script actions so that we can quickly find things that need editing?

Good call. I've also added it to the original post.

Great suggestion. Done.

Yup. Done.

Great minds think alike. I disabled Timeout Aborts Macro in the Copy action when going through Peter's suggestions, which seems to have taken care of it quite neatly.

Done!

Thanks for pointing that out. I'll adjust the wording of the post to make it less Forum-centric.

Thanks guys!

1 Like

This is a really nice macro @noisneil - thanks!

Here's a tip for users of PopClip who wish to trigger your macro using PopClip. It's very easy to do and here's how my PopClip tool looks (highlighted with the red box) after I've configured it to run your macro:

image

PopClip works by popping up that little menu whenever you select something. In this example I've selected the text Here's a tip for users and immediately up pops the PopClip menu, the first item being your macro. You can see some other items in the menu such as Typinator and other basic actions. Clicking on that menu item then brings up your macro with whatever has been selected.

To install your macro into PopClip you just need to select the following text and when PopClip appears choose the Install Extension "KMStyle" and that's it!

# popclip
name: KMStyle
url: kmtrigger://macro=Style%20Text%20%28Markdown%2FHTML%29

Having done that you can then re-order the PopClip menu so it looks the way you want it.

More information on PopClip extensions etc. can be found here and thanks to @appleianer here:

Please note:

  1. I don't have any affiliation with the makers of PopClip - I'm just a satisfied user.
  2. I've chosen to use the URL trigger "by name" for your macro as shown below but you can also use the URL trigger "by UUID" if you prefer.
    image
2 Likes

BRB, rushing to install PopClip...

Brilliant!!!

2 Likes

BTW, can you guess what the second item in my PopClip menu runs?

image

Clue: ask @_jims :pray:

2 Likes