Supported formatting in posts (markdown, BBCode, and HTML)

There are three things to consider.

  1. What Markdown is allowed?

  2. What BBCode is allowed?

  3. What HTML is allowed?

All 3 can be mixed and merged to some extent.


Our implementation uses Markdown-it.

You can see a complete interactive list of the formatting syntax here:


We support a subset of “common” BBCode.

As for what BBCode is supported, the best place to look is the tests (app/assets/javascripts/discourse/tests/unit/lib/pretty-text-test.js), and here’s what I see there:

[ul][li]option one[/li][/ul]



Custom BBCode specific to Discourse, needed for functions that don’t fit into Markdown, but do fit into BBCode.

[spoiler]it's a sled[/spoiler]
[quote="eviltrout, post:1, topic:2"]


Markdown specifies that it works seamlessly with HTML, so we do.

However, we only support a “safe” subset of HTML.
See the list of supported tags and attributes here: discourse/allow-lister.js at main · discourse/discourse · GitHub


None of these references mention tables.

That is true but this other topic does. Add a table to your post using markdown


Text color and text background color doesn’t seem to work with <span> or bbcode, am I missing something?

  • <span style="color:red">some red markdown text</span>
    • some red markdown text
  • bbcode: [color=red]Red color text[/color]
    • [color=red]Red color text[/color]
1 Like

yes, looks like HTML inline style is not supported

You’ll have either to use this and allow specific colors by yourself:

(You can see it in action here: 📜 [Wiki] Schlumpf hub serial numbers reference - Unicycles and Equipment -

Or use this plugin that extends BBcode support:

As for the allowed HTML tags, I believe this is the reference:

Though I don’t find table HTML tags (which are allowed) inside for some reason.

Maybe because they are referenced here:


Thanks a lot for the useful references!

It looks like currently, the filter is set up so that the rowspan and colspan attributes on td and th elements are filtered out. My understanding is that these are safe (and I believe they are very useful): would the team be open to allowing these attributes?

As a sidebar, @Canapin talked about the location of the allowed list of table tags.

The .../discourse-markdown/table.js file, though, seems to be an implementation around specifically Markdown tables; would regular HTML tables need a separate extension to allowList?

I believe rowspan and colspan are pretty safe, but I also want to ask for one other piece of markup. Could we allow data-* attributes on table elements? I think this would be very useful for specifying different types of table contents, in particular to use as hooks for custom CSS.

1 Like

Hi :slight_smile:

I think this would be trickier than expected.
If you create an HTML table in your post, and someone quotes your table, it’s converted into Markdown which doesn’t support rowspan and colspan.

I suspect there would be other issues I didn’t think about.

It’s not exactly the same, but you can wrap your table with [wrap] tags :slight_smile:
See: Customize posts' contents with your own styles
But you won’t be able to have data- attributes inside an HTML table (for example, to customize specific rows or cells).

edit: if your table uses Markdown instead of HTML, you can insert spans with data- attributes like this:

|Column 1 | Column 2|
|--- | ---|
|<span data-thing>test</span> | test|
|test | test|

But they will be removed if someone quotes or copy-paste your table.

1 Like