Hi. I was wondering if anyone would be so kind as to make a simple syntax for use on WhatsApp.
Italic: _text_
Bold: *text*
Strikethrough: ~text~
Monospace: ```text```
I went through the documentation for creating a new syntax but am afraid that it is beyond me. I’m sure this would be helpful to many people. Thanks!
I’ve been waiting for this forever.
Try this one…think it covers the basics described in that link:
Thank you for this @agiletortoise but I can’t get it to work as expected. After installing it I am still getting two asterisks when I try to make text bold.
Also, could you please tell me how to format text as Strikethrough and Monospace?
Just installing a syntax has no effect other than making it available to assign to drafts. By default, Drafts uses the built-in Markdown syntax for new drafts, you would need to override that on a draft-by-draft basis, or change your default option for newly created drafts to use the WhatsApp syntax.
Details on syntax highlighting in the guide.
You can also create individual drafts with a syntax on iOS by long-pressing the “+”, or via File menu on Mac, and selecting “New with Syntax…”
Sorry, I should have specified that I am unable to use the WhatsApp syntax even after changing over to it in a draft or creating a new draft using the “New with Syntax…” option. The draft shows WhatsApp in the syntax menu at the bottom but when I select text and press Command+B it still uses double asterisks instead of the single ones for the WhatsApp syntax.
Ok, you are wanting several things here…and I’m not sure what your end goal is, which might alter how you want to proceed.
A syntax only controls how display styles are applied in the editor. If you have a draft assigned the WhatsApp syntax, you can type *bold*
and you would get the output you want.
As for commands that manipulate text, those are all implemented in actions in your action list. By default, drafts ships with a “Markdown Bold” action which is bound to the keyboard shortcut command-B
, and applies Markdown bold formatting to the selected text (either wrapping a text selection with **
or inserting it if there is no selection).
In a default installation, that action is in the “Markdown” action group. You can edit that action and change it to insert a single *
if you desire. Which might be what you want if you are only using WhatsApp - the line to change is at the beginning of the one script in that action at looks like, you would just remove one of the asterisks:
// Apply Markdown bold to selection, or insert ** if no selection
const markup = "**";
That would, of course, make it always only insert one asterisk. If you also use Markdown, that might not be desireable. If you wanted to make it smart and syntax sensitive, you could check for the current syntax assignment and replace that one line above in the action with the following:
let markup = "**"
if (draft.syntax.name == "WhatsApp") {
markup = "*"
}
This would only switch to the single *
if the WhatsApp syntax is assigned to the current draft.
This is exactly what I needed. I had searched on the directory before, but couldn’t find it.
On macOS it only showed up available on the bottom bar after creating a ‘new with syntax’ using the File menu, though.
Thanks.