Generic [wrap]/Markdown-it Custom Token Types causing errors in RTE

AI-generated summary

Users reported issues with custom BBCode tags (like [wrap] and [g rid]) causing errors or unexpected behavior when toggling between Markdown and Rich Text Editor (RTE) modes in Discourse. The root cause is the lack of ProseMirror schema support for custom token types, leading to escaped or hidden content and parser errors such as No parser processed bbcode_open token for tag: div. While the issue was initially low priority, it affected usability, especially for plugins using generic tags like [wrap]. A temporary workaround is to use Markdown mode only. The Discourse team, including @renato, acknowledged the problem and confirmed it’s being addressed. As of renato, [wrap] is now supported in the rich editor, and the topic is closed — users are encouraged to open new reports for any remaining issues. Other users like sam, pierrox, and Canapin confirmed similar experiences and noted the importance of such tags for layout (e.g., image grids). The ideal long-term fix involves plugins defining their own ProseMirror schemas, with plain text fallbacks for unhandled tags.

Priority/Severity: Low?

Platform: Devices using new RTE.

Description: Creating custom token types, which previously worked fine with just the markdown-it engine, causes errors with ProseMirror. As without a ProseMirror schema to handle the parsed to DOM, any custom token types create an error. Similarly there are behavior issues when toggling between RTE and Markdown with BBCode.

Reproducible steps:

RTE First:

  1. Open Editor
  2. Set mode to RTE
  3. Insert custom BBCode.
    a. For example with Discourse Meta: [wrap=test2 user-id=1]Content[/wrap]
  4. Dismiss error and toggle between RTE and md mode.
    a. BBCode is escaped

Markdown First:

  1. Open Editor
  2. Set mode to Markdown
  3. Insert custom BBCode.
  4. Toggle between md mode and RTE.
    a. BBCode is not visible
  5. Toggle back to see raw.

Current workaround:
Use Markdown mode only instead.


Getting the error itself isn’t that big of a deal, the bigger issue is with the weird behavior when toggling or when inserting the code.

The ideal solution would be for every markdown plugin to create a proper wizard/ProseMirror schema to handle it.

With regards to the generic [wrap] bbcode, perhaps just letting it stay in plain text is best, since multiple components could be using the generic bbcode in the same Discourse instance. The ideal solution is probably to let devs create a custom wizard and match the output to their own implementations, and let it fallback to plain text if no matches are found.

More generally, with any existing plugins that haven’t been updated to use ProseMirror, letting it default to plain text (that isn’t escaped/hidden) would be a nice interim fallback.

3 Likes

Thanks for reporting, @renato is keeping an eye out for edge cases like this, wrap has been our go-to for certain theme components, we will get it working.

2 Likes

I get a similar error message if I add the Gallery tag [grid]in Markdown and then re-edit my post in WYSIWYG mode.

I understand the issue is known and worked on, I just add the actual error message:

No parser processed bbcode_open token for tag: div, attrs: [["class","d-image-grid"]]

For folks who will search this string on meta after experiencing this issue (like I just did). :slight_smile:

1 Like

We are aware, issue indeed is being worked on, should have it resolved in a few weeks.

3 Likes

Ran into this myself. Glad that its being worked on.

Grid makes the posts look beautiful instead of a horrible mess when users upload multiple images in the post.

[wrap] is now supported on the rich editor, I’m closing this but please feel free to open a new topic if you find any issues.

1 Like