Hey Ilya,
Bracketing the text with three back-ticks – ``` (Lower-case of the tilde ~ key.)
```
tell application "Mail"
tell (some message viewer whose index is 1)
set msg to item 1 of (get selected messages)
end tell
end tell
```
Will cause the text to render as code.
tell application "Mail"
tell (some message viewer whose index is 1)
set msg to item 1 of (get selected messages)
end tell
end tell
You can also add the type of code to the first back-tick line.
Try:
```applescript your code ```
```text your code ```
```bash your code ```
And see the difference.
I believe the default for just three back-ticks is AppleScript, although Peter would have to confirm.
My post here would be worth reading, and some of the other conversation:
Best Practices for GUI Scripting
There's a long thread on the Keyboard Maestro forum:
Learning & Using AppleScript & JavaScript for Automation (JXA)
There's the Scripting page on the Keyboard Maestro wiki.
I have about 5 books on AppleScript myself.
I usually recommend these two:
"Learn AppleScript: The Comprehensive Guide to Scripting and Automation on Mac OS X"
"AppleScript: The Definitive Guide"
I've heard good things about “AppleScript 1,2,3”, although I haven't had my hands on it.
Apple broke AppleScripting signatures in Sierra and hasn't fixed it.
-Chris