Is it possible to search the clipboard and style text between specific characters

I have a script that copies text from a txt file on my desktop to the clipboard and pastes it to an email. In that text are some headers that are plain text surrounded by asterisks like this *Header title*. Is it possible to search that clipboard and format just those headers bold?

Hey David,

No, you can’t do that with Keyboard Maestro actions.

Applying style to the clipboard doesn’t include a bold option.

That said – it can be done.

Search for “convert rtf” and/or “textutil” on the forum.

If you know a little HTML and CSS you can get pretty fancy.

A simple example:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" ""> 
<html xmlns="" xml:lang="de">     
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />   
        <title>Hi, I'm bold!</title>  
        <style type="text/css">
            p {
        <p>Hi, I'm very bold and HUGE!</p>
        Line One<br>
        Line Two<br>
        Line Three<br>

If your file is already in the clipboard as HTML code, you can run this shell script from an Execute a Shell Script action:

pbpaste | textutil -convert rtf -stdin -stdout | pbcopy

You can also read it directly from the file or from a Keyboard Maestro variable.