Automatically read a document and bound specific words/terms with special character (asterisk)

Hey KM Friends!

Not a coder, but hoping someone could think of a way I could have KM scan the current text selection or document and search for specific words (about 5 different terms, words) and then bound them with a special character (asterisk).

Example: I would want ipsum and sit bound with asterisks.

This: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Would become this: Lorem *ipsum* dolor *sit* amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Any ideas? Trying to speed up Jira workflow...

Below is just an example written in response to your request. You will need to use as an example and/or change to meet your workflow automation needs.

Note that you asked to "search for specific words", and this macro does that using the Regex definition of a "word" based on Regex Word Boundaries.

Also while you asked for bound the found words with an "*", this macro allows a separate setting for the prefix and suffix to be added to the found word.

Please let us know if it meets your needs.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Example Output

MACRO:   Apply Prefix and Suffix to Words in Selection [Example]

-~~~ VER: 1.0    2021-04-30 ~~~
Requires: KM 8.2.4+   macOS 10.11 (El Capitan)+
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

DOWNLOAD Macro File:

Apply Prefix and Suffix to Words in Selection [Example].kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


ReleaseNotes

Author.@JMichaelTX

PURPOSE:

  • Apply Prefix and Suffix to Words in Selection

HOW TO USE

  1. First, make sure you have followed instructions in the Macro Setup below.
  2. See the below "How to Use" Comment Action
  3. This macro is just an example written in response to your request. You will need to use as an example and/or change to meet your workflow automation needs.

MACRO SETUP

  • Carefully review the Release Notes and the Macro Actions
    • Make sure you understand what the Macro will do.
    • You are responsible for running the Macro, not me. ??
      .
      Make These Changes to this Macro
  1. Assign a Trigger to this Macro .
  2. Move this macro to a Macro Group that is only Active when you need this Macro.
  3. ENABLE this Macro, and the Macro Group it is in.
    • For more info, see KM Wiki article on Macro Activation
      .
  • REVIEW/CHANGE THE FOLLOWING MACRO ACTIONS:
    (all shown in the magenta color)
    • CHANGE to Your List of Words To Find
      • One word per line
    • CHANGE to Your Prefix String
      • One or or more characters on one line
    • CHANGE to Your SUFFIX String
      • One or or more characters on one line

REQUIRES:

  1. KM 9.0+ (may work in KM 8.2+ in some cases)
  2. macOS 10.12.6 (Sierra)+

TAGS: @Example

==USE AT YOUR OWN RISK==

  • While I have given this a modest amount of testing, and to the best of my knowledge will do no harm, I cannot guarantee it.
  • If you have any doubts or questions:
    • Ask first
    • Turn on the KM Macro Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.

2 Likes

Thanks! I'll give it a shot.