Generieke [wrap]/Markdown-it Custom Token Types veroorzaken fouten 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

Bedankt voor je melding, @renato houdt dit soort randgevallen in de gaten, wrap is onze standaardoplossing voor bepaalde themacomponenten, we zullen het werkend krijgen.

2 likes

Ik krijg een vergelijkbaar foutbericht als ik de Gallery-tag [grid] in Markdown toevoeg en mijn bericht vervolgens opnieuw bewerk in WYSIWYG-modus.

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 zijn ervan op de hoogte, het probleem wordt inderdaad aangepakt en zou binnen enkele weken opgelost moeten zijn.

3 likes

Dit ben ik zelf ook tegengekomen. Fijn dat er aan gewerkt wordt.

Grid zorgt ervoor dat de berichten er mooi uitzien in plaats van een vreselijke puinhoop wanneer gebruikers meerdere afbeeldingen in het bericht uploaden.

[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