How to format text and use control characters?#
When sending text through an API or integration, sometimes difficulties arise with the formatting of the message. In this article we will answer the most common questions about working with text:
1. How to format text and use control characters?#
Formatting messages:
Display | Formatting | Description |
---|---|---|
Italic text | _Italic text_ | Enclose text between two underscores (_ ) |
Bold text | *bold text* | Enclose text between two asterisks (* ) |
~strikethrough text~ | Enclose text between two tildes (~ ) | |
Monospace text | ```fixed space text``` | Enclose text between two sets of triple backquote (``` ) |
Text with embedded code | `Text with embedded code` | Enclose text between two backquotes (` ) |
Quoting text | > Quoting text | Place a greater-than symbol (> ) and a space before the text |
| * First item - Second item | Place an asterisk (* ) or a hyphen (- ) and a space before each item. Only sent correctly through WhatsApp Messenger, WhatsApp Business, or WhatsApp Web |
| 1. First item 2. Second item | Place a number with a dot (1. ) and a space before each item. Only sent correctly through WhatsApp Messenger, WhatsApp Business, or WhatsApp Web |
If you need to keep the display of these symbols in the text, you must place the symbol twice without spaces.
For example, if you need to send "_text with an underscore_", and not "italic text", then at the beginning of the text, you should add two underscores: "__text with an underscore__"
2. How to use control characters?#
Control characters, also known as escape sequences, are a series of two or more characters starting with a backslash \
. They allow you to insert special characters and execute certain commands in text strings.
These characters can be used in many programming languages and command-line interfaces.
character | Formatting | Description |
---|---|---|
\n | Line break\non new line | Line break. Enter a backslash followed by the letter n in lowercase after the word where you want to insert a line break without spaces |
\t | Add\ttabulation | Tabulation. Enter a backslash followed by the letter t in lowercase after the word where you want to insert a tabulation without spaces |
\r | Cursor return\rto beginning | Cursor return to the beginning. Enter a backslash followed by the letter r in lowercase after the word where you want to return the cursor without spaces |
\" | Text with \"quotes\" | To send text with quotes, enter a backslash followed by a quote symbol where they are used |
\' | Text with \'single quote\' | To send text with a single quote, enter a backslash followed by a single quote (apostrophe) symbol where they are used |
\\ | Text with \\backslash | To send text with a backslash, enter this symbol twice where they are used |