Simply, can a variable paste formatted ie. BOLD text?

I’ve looked on the forum and sometimes it gets so deep I can’t see the simple answer I’m looking for.
Simply, have a full paragraph of simple, plain text, (stored and used over and over as a variable) and one word needs to be bold or italicized, is this possible with a variable or do I need to get it to a clipboard?

It’s probably right in front of me.

1 Like

Variables are plain text strings. They cannot include formatting.

What are you wanting to do specifically? Paste the text in? The easiest is to use Insert Styled Text by Pasting which can include formatted text.

Alternatively, you can copy the styled text to a Named Clipboard and use that in place of your variable (including in the Insert Styled Text by Pasting action for example) using the NamedClipboard token.

2 Likes

Ok, thanx.
The use is:
I’m using a variable to ‘fill’ the body of an email using the ‘send mail message’ action.
The variable is built up quite nicely using an initial ‘template’ and then ‘replacing’ 15-20 ‘variables’ within the body.
The ‘email’ is completely comprised, the one lacking part is getting that one word ‘bolded’.

  • That word is static in the ‘email template’ variable. meaning it’s always there.
    I understand I could ‘locate’ to the top or bottom of the email and command-arrow, (or whatever mechanism I chose) to the word and then ‘bold’ it.
    But was wondering if there was a more elegant way to do it.
    What I’m getting is that I would have to create a 'named clipboard’
    out of the variables and then ‘paste’ that clipboard in the body of the email.
  • it’s a bit of a drag getting out of the ‘programming’ of KM to have to paste, but if that’s what it is, that’s fine.
    Appreciate the time and effort. ~

I don't use Apple Mail much (only for testing), so others that do may have a better solution.

AFAIK, you can't use AppleScript to find text in the Mail Compose window, and then format it somehow.

However, this can be done in TextEdit with AppleScript.
So, one approach is to build up the text in TextEdit, find and bold the words of interest, then copy to the Mail Compose window.

A bit laborious, but once you have it, it could be quite useful.

Good luck!

1 Like

First thought would be to use Markdown conventions in the plain text, and convert from MD to RTF formatted (perhaps via off-the-peg MD -> HTML) in the clipboard.

(Automating http://marked2app.com/ might be one approach)

(Or install Node.js, then npm install commonmark – see https://github.com/jgm/commonmark.js)

1 Like