Back to Mattermost

Format messages

docs/main/end-user-guide/collaborate/format-messages.mdx

11.10.020.2 KB
Original Source

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

<PlanAvailability slug="all-commercial" />

Use the messaging formatting toolbar

From Mattermost v7.0, you can format your messages in Mattermost using the message formatting toolbar without having to specify any Markdown syntax.

The message formatting toolbar offers the following formatting options:

<table> <colgroup> <col style={{width: '53%'}} /> <col style={{width: '46%'}} /> </colgroup> <tbody> <tr> <td rowspan="2"><blockquote> <p><strong>Formatting option</strong></p> </blockquote> <dl> <dt>==================================================================================</dt> <dd> <p><a href="#use-markdown">Bold, italicize, or strike out text</a></p> </dd> </dl></td> <td rowspan="2"><blockquote> <p><strong>Icon</strong> |</p> </blockquote> <dl> <dt>=========================+</dt> <dd> <p><a href="mm-subst:bold-icon">bold-icon</a> | <a href="mm-subst:italics-icon">italics-icon</a> | <a href="mm-subst:strikeout-icon">strikeout-icon</a> |</p> </dd> </dl></td> </tr> <tr> </tr> <tr> <td>Add <a href="#headings">headings</a>, <a href="#links">links</a>, or attachments</td> <td><a href="mm-subst:headings-icon">headings-icon</a> | <a href="mm-subst:copy-link-icon">copy-link-icon</a> | <a href="mm-subst:attachments-icon">attachments-icon</a> |</td> </tr> <tr> <td>Format a numbered list, a bulleted list, quoted text, or text as code</td> <td><a href="mm-subst:numbered-icon">numbered-icon</a> | <a href="mm-subst:bullets-icon">bullets-icon</a> | <a href="mm-subst:quotes-icon">quotes-icon</a> | <a href="mm-subst:code-icon">code-icon</a> |</td> </tr> <tr> <td colspan="2"><a href="mm-doc:%2Fend-user-guide%2Fcollaborate%2Freact-with-emojis-gifs">Add emojis or GIFs</a> | <a href="mm-subst:emoji-icon">emoji-icon</a> |</td> </tr> <tr> <td colspan="2"><a href="mm-doc:%2Fend-user-guide%2Fcollaborate%2Fmessage-priority">Set message priority</a> | <a href="mm-subst:message-priority-icon">message-priority-icon</a></td> </tr> </tbody> </table>

Review how your message formatting will look when the message is sent by selecting the Show/Hide Preview icon. Return to your draft message by selecting the icon again.

<Tip>
  • Hide the formatting options by selecting the Show/Hide Formatting icon. Select the icon again to show the formatting options.
  • You can control whether post formatting is rendered within the message formatting editor. When disabled, raw text is shown. See the Channels customization documentation for details.
</Tip>

Use Markdown

You can also format your messages in Mattermost using Markdown to control text styling, links, headings, lists, code blocks, in-line code, in-line images, horizontal lines, block quotes, tables, and math formulas. Markdown makes it easy to format messages: type a message as you normally would, then use formatting syntax to render the message a specific way. For a guide to using Markdown in Mattermost, see this blog post.

Text style

You can use either _ or * around a word or phrase to make it italic, or __ or ** around a word or phrase to make it bold.

<Tip>

Common formatting keyboard shortcuts are supported. Bold text by pressing <kbd>Ctrl</kbd> <kbd>B</kbd> on Windows and Linux, or <kbd></kbd> <kbd>B</kbd> on Mac. Italicize text by pressing <kbd>Ctrl</kbd> <kbd>I</kbd> on Windows or Linux, or <kbd></kbd> <kbd>I</kbd> on Mac.

</Tip>
  • *italics* (or _italics_) renders as italics
  • **bold** renders as bold
  • ***bold-italic*** renders as
  • ~~strikethrough~~ renders as
<Tip>

Format selected message text as a link by pressing <kbd>Ctrl</kbd> <kbd>K</kbd> on Windows and Linux, or by pressing <kbd></kbd> <kbd>K</kbd> on Mac.

</Tip>

Channel links

Create a link to a public channel in a message by typing ~ followed by the channel name (e.g. ~roadmap). Channel members see private channel names returned.

Labeled links

Create labeled links by putting the desired text in square brackets [ ] and the associated link in round brackets ( ).

[Check out Mattermost!](https://.mattermost.com/)

Renders as: Check out Mattermost!

Headings

Make a heading by typing # and a space before your title. For smaller headings, use more #'s.

text
## Large Heading
### Smaller Heading
#### Even Smaller Heading

Renders as:

Alternatively, you can underline the text using equal signs === or hyphens --- to create headings.

text
Large Heading
-------------

Renders as:

Lists

Create a list by using asterisks *, hyphens -, and/or plus signs + interchangeably as bullets. Indent bullet points by adding two spaces in front each one.

text
* item one
- item two
  + item two sub-point

Renders as:

  • item one
  • item two
    • item two sub-point

Make an ordered list by using numbers instead:

text
1. Item one
1. Item two
1. item three

Renders as:

  1. Item one
  2. Item two
  3. Item three

You can also start a list at any number:

text
4. The first list number is 4.
1. The second list number is 5.
1. The third list number is 6.

Renders as:

  1. The first list number is 4.
  2. The second list number is 5.
  3. The third list number is 6.

Make a task list by including square brackets [ ]. Mark a task as complete by adding an x.

text
- [ ] Item one
- [ ] Item two
- [x] Completed item

Renders as:

Code blocks

Creating a fixed-width code block is recommended for pasting multi-line blocks of code or other text output because it's easier to read with fixed-width font alignment. Examples include block text snippets, ASCII tables, and log files. Rendered code blocks include a Copy option to copy the contents of the code block.

This can be accomplished by placing three backticks ` on the line directly above and directly below your code: .. code-block:: text ``<code> this is my code block </code>`.. tip:: Type three backticks```<code>, press \`Shift \<mm-kbd:\></code>\_\_ <kbd>Enter</kbd> on Windows or Linux, or <kbd>⇧</kbd> <kbd>↵</kbd> on Mac, `<type_your_code>`, press <kbd>Shift</kbd> <kbd>Enter</kbd> on Windows or Linux, or <kbd>⇧</kbd> <kbd>↵</kbd> on Mac again, then type three more backticks . Or by indenting each line by four spaces: .. code-block:: text this is my code block ^^^^ 4x spaces Syntax highlighting ^^^^^^^^^^^^^^^^^^^^ To add syntax highlighting, type the language to be highlighted after the ````\ at the beginning of the code block. Mattermost also offers four different code themes (GitHub, Solarized Dark, Solarized Light, and Monokai) that can be changed in Settings > Display > Theme > Custom Theme > Center Channel Styles.

Supported languages and their aliases include:

<table width="100%" border="1" cellpadding="5px" style={{marginBottom: '20px'}}> <tr class="row-odd"> <th class="head">Language</th> <th class="head">Aliases</th> </tr> <tr class="row-odd"> <td valign="middle">ActionScript</td> <td valign="middle">actionscript, as, as3</td> </tr> <tr class="row-odd"> <td valign="middle">AppleScript</td> <td valign="middle">applescript</td> </tr> <tr class="row-odd"> <td valign="middle">Bash</td> <td valign="middle">bash, sh</td> </tr> <tr class="row-odd"> <td valign="middle">Clojure</td> <td valign="middle">clojure</td> </tr> <tr class="row-odd"> <td valign="middle">CoffeeScript</td> <td valign="middle">coffescript, coffee, coffee-script</td> </tr> <tr class="row-odd"> <td valign="middle">C/C++</td> <td valign="middle">cpp, c++, c</td> </tr> <tr class="row-odd"> <td valign="middle">C#</td> <td valign="middle">cs, c#, csharp</td> </tr> <tr class="row-odd"> <td valign="middle">CSS</td> <td valign="middle">css</td> </tr> <tr class="row-odd"> <td valign="middle">D</td> <td valign="middle">d, dlang</td> </tr> <tr class="row-odd"> <td valign="middle">Dart</td> <td valign="middle">dart</td> </tr> <tr class="row-odd"> <td valign="middle">Delphi</td> <td valign="middle">delphi</td> </tr> <tr class="row-odd"> <td valign="middle">Diff</td> <td valign="middle">diff, patch, udiff</td> </tr> <tr class="row-odd"> <td valign="middle">Django</td> <td valign="middle">django</td> </tr> <tr class="row-odd"> <td valign="middle">Dockerfile</td> <td valign="middle">dockerfile, docker</td> </tr> <tr class="row-odd"> <td valign="middle">Elixir</td> <td valign="middle">elixir, ex, exs</td> </tr> <tr class="row-odd"> <td valign="middle">Erlang</td> <td valign="middle">erlang, erl</td> </tr> <tr class="row-odd"> <td valign="middle">Fortran</td> <td valign="middle">fortran</td> </tr> <tr class="row-odd"> <td valign="middle">F#</td> <td valign="middle">fsharp</td> </tr> <tr class="row-odd"> <td valign="middle">G-Code</td> <td valign="middle">gcode</td> </tr> <tr class="row-odd"> <td valign="middle">Go</td> <td valign="middle">go, golang</td> </tr> <tr class="row-odd"> <td valign="middle">Groovy</td> <td valign="middle">groovy</td> </tr> <tr class="row-odd"> <td valign="middle">Handlebars</td> <td valign="middle">handlebars, hbs, mustache</td> </tr> <tr class="row-odd"> <td valign="middle">Haskell</td> <td valign="middle">haskell, hs</td> </tr> <tr class="row-odd"> <td valign="middle">Haxe</td> <td valign="middle">haxe</td> </tr> <tr class="row-odd"> <td valign="middle">Java</td> <td valign="middle">java</td> </tr> <tr class="row-odd"> <td valign="middle">JavaScript</td> <td valign="middle">javascript, js</td> </tr> <tr class="row-odd"> <td valign="middle">JSON</td> <td valign="middle">json</td> </tr> <tr class="row-odd"> <td valign="middle">Julia</td> <td valign="middle">julia, jl</td> </tr> <tr class="row-odd"> <td valign="middle">Kotlin</td> <td valign="middle">kotlin</td> </tr> <tr class="row-odd"> <td valign="middle">LaTeX</td> <td valign="middle">latex, tex</td> </tr> <tr class="row-odd"> <td valign="middle">Less</td> <td valign="middle">less</td> </tr> <tr class="row-odd"> <td valign="middle">Lisp</td> <td valign="middle">lisp</td> </tr> <tr class="row-odd"> <td valign="middle">Lua</td> <td valign="middle">lua</td> </tr> <tr class="row-odd"> <td valign="middle">Makefile</td> <td valign="middle">makefile, make, mf, gnumake, bsdmake</td> </tr> <tr class="row-odd"> <td valign="middle">Markdown</td> <td valign="middle">markdown, md, mkd</td> </tr> <tr class="row-odd"> <td valign="middle">Matlab</td> <td valign="middle">matlab, m</td> </tr> <tr class="row-odd"> <td valign="middle">Objective C</td> <td valign="middle">objectivec, objective_c, objc</td> </tr> <tr class="row-odd"> <td valign="middle">OCaml</td> <td valign="middle">ocaml</td> </tr> <tr class="row-odd"> <td valign="middle">Perl</td> <td valign="middle">perl, pl</td> </tr> <tr class="row-odd"> <td valign="middle">Pascal</td> <td valign="middle">pascal, pas</td> </tr> <tr class="row-odd"> <td valign="middle">PostgreSQL</td> <td valign="middle">pgsql, postgres, postgresql</td> </tr> <tr class="row-odd"> <td valign="middle">PHP</td> <td valign="middle">php, php3, php4, php5</td> </tr> <tr class="row-odd"> <td valign="middle">PowerShell</td> <td valign="middle">powershell, posh</td> </tr> <tr class="row-odd"> <td valign="middle">Puppet</td> <td valign="middle">puppet, pp</td> </tr> <tr class="row-odd"> <td valign="middle">Python</td> <td valign="middle">python, py</td> </tr> <tr class="row-odd"> <td valign="middle">R</td> <td valign="middle">r, s</td> </tr> <tr class="row-odd"> <td valign="middle">Ruby</td> <td valign="middle">ruby, rb</td> </tr> <tr class="row-odd"> <td valign="middle">Rust</td> <td valign="middle">rust, rs</td> </tr> <tr class="row-odd"> <td valign="middle">Scala</td> <td valign="middle">scala</td> </tr> <tr class="row-odd"> <td valign="middle">Scheme</td> <td valign="middle">scheme</td> </tr> <tr class="row-odd"> <td valign="middle">SCSS</td> <td valign="middle">scss</td> </tr> <tr class="row-odd"> <td valign="middle">Smalltalk</td> <td valign="middle">smalltalk, st, squeak</td> </tr> <tr class="row-odd"> <td valign="middle">SQL</td> <td valign="middle">sql</td> </tr> <tr class="row-odd"> <td valign="middle">Stylus</td> <td valign="middle">stylus, styl</td> </tr> <tr class="row-odd"> <td valign="middle">Swift</td> <td valign="middle">swift</td> </tr> <tr class="row-odd"> <td valign="middle">Text</td> <td valign="middle">text</td> </tr> <tr class="row-odd"> <td valign="middle">TypeScript</td> <td valign="middle">typescript, ts, tsx</td> </tr> <tr class="row-odd"> <td valign="middle">VB.Net</td> <td valign="middle">vbnet, vb, visualbasic</td> </tr> <tr class="row-odd"> <td valign="middle">VBScript</td> <td valign="middle">vbscript</td> </tr> <tr class="row-odd"> <td valign="middle">Verilog</td> <td valign="middle">verilog</td> </tr> <tr class="row-odd"> <td valign="middle">VHDL</td> <td valign="middle">vhdl</td> </tr> <tr class="row-odd"> <td valign="middle">HTML, XML</td> <td valign="middle">html, xml</td> </tr> <tr class="row-odd"> <td valign="middle">YAML</td> <td valign="middle">yaml, yml</td> </tr> </table>

Example:

text
``` go
package main
import "fmt"
func main() {
    fmt.Println("Hello, 世界")
}
```

Renders as:

GitHub Theme

Solarized Dark Theme

Solarized Light Theme

Monokai Theme

In-line code

Create in-line monospaced code text by surrounding it with backticks ``<code>. Don't use single quotes </code><code>'</code>`.

text
`monospace`

Renders as: monospace.

In-line images

In-line images are images added within lines of text. You can control whether all in-line images over 100px in height are automatically collapsed or expanded in messages by setting a user preference, or by using the /collapse and /expand slash commands.

To add in-line images to text, use an exclamation mark ! followed by the alt text in square brackets [ ], then the image URL in round brackets ( ). You can add hover text after the link by placing the text in quotes " ".

Example:

text
![alt text](URL of image "Hover text")

If the height of the original image is more than 500 pixels, Mattermost sets the image height at 500 pixels and adjusts the width to maintain the original aspect ratio.

You can set the width and height of the displayed image after the URL of the image by using an equals sign = followed by values for both width and height ##x##. If you set only the width, Mattermost adjusts the height to maintain the original aspect ratio.

<Warning>

The native apps do not support fixed width and height and will display the full-size image.

</Warning>

Examples:

text
.. |mattermost-icon-76x76| image:: ../images/icon-76x76.png
.. |mattermost-icon-50x76| image:: ../images/icon-50x76.png

In-line image with hover text

text
![Mattermost](/images/icon-76x76.png "Mattermost Icon")

Renders as:

In-line image with link

<Note>

An extra set of square brackets [ ] is required around the alt text, and round brackets ( ) are required around the image link.

</Note>
text
[![Mattermost](/images/icon-76x76.png)](https://github.com/mattermost/mattermost)

Renders as:

In-line image displayed with fixed width and height

Example: An in-line image that's 50 pixels wide and 76 pixels high.

text
![Mattermost](/images/icon-76x76.png =50x76 "Mattermost Icon")

Renders as:

In-line image displayed with fixed width

Example: An in-line image that's 50 pixels wide where the system adjusts the height to maintain the original aspect ratio.

text
![Mattermost](/images/icon-76x76.png =50 "Mattermost Icon")

Renders as:

Horizontal lines

Create a line by using three *, _, or -.

***

Renders as:


Block quotes

Create block quotes using >.

> block quotes renders as:

Tables

Create a table by placing a dashed line --- under the header row, then separating each column with using pipes |. The columns don’t need to line up exactly. Choose how to align table columns by including colons : within the header row.

text
| Left-Aligned  | Center Aligned  | Right Aligned |
| :------------ |:---------------:| -----:|
| Left column 1 | this text       |  $100 |
| Left column 2 | is              |   $10 |
| Left column 3 | centered        |    $1 |

Renders as:

<Note>

Multi-line text in a table cell isn't supported using HTML tags such as or .

</Note>

Math Formulas

<Tabs> <TabItem value="using-inline-latex" label="Using Inline LaTeX">

You can create formulas that display inline using LaTeX. Use the dollar sign ($) symbol at the beginning and end of each formula.

<Note>

This feature is disabled by default. Contact your system admin to enable this setting in System Console > Site Configuration > Posts to use this feature.

</Note>
text
$X_k = \sum_{n=0}^{2N-1} x_n \cos \left[\frac{\pi}{N} \left(n+\frac{1}{2}+\frac{N}{2}\right) \left(k+\frac{1}{2}\right) \right]$

Renders as:

</TabItem> <TabItem value="using-latex-in-code-blocks" label="Using LaTeX in Code Blocks">

Create formulas as code blocks by using LaTeX in a latex code blocks.

<Note>

This feature is disabled by default. Contact your system admin to enable this setting in System Console > Site Configuration > Posts to use this feature.

</Note>
text
```latex
X_k = \sum_{n=0}^{2N-1} x_n \cos \left[\frac{\pi}{N} \left(n+\frac{1}{2}+\frac{N}{2}\right) \left(k+\frac{1}{2}\right) \right]
```

Renders as:

</TabItem> </Tabs> <PlanAvailability slug="academy-message-formatting" />