Skip to content

Content Editor: Support pre tags used for other purposes than defining code blocks in client-side parser

What does this MR do and why?

This MR adds support for declaring pre tags outside of their common usage in code blocks. When a Markdown renderer converts Markdown into HTML, code blocks usually look like this:

<pre lang="javascript">
 <code>
   Code
 </code>
</pre>

There are cases where you may find the pre tag used outside this use case. The example 118 of the GFM spec demonstrates it: https://github.github.com/gfm/#example-118

This MR adds support for pre tags by telling the client-side Markdown renderer to skip rendering of code blocks and preserve the original Code Block node coming from the Markdown AST. This allows us to have two separate converters in the Hast to ProseMirror converter: One for pre tags and another for code blocks.

Screenshots or screen recordings

Before After
2022-07-13_16.53.42 2022-07-13_16.52.02

How to set up and validate locally

  1. Enable the preserve_unchanged_markdown feature flag.
  2. Edit or create a Wiki page
  3. Paste the following snippets in the Classic Markdown Editor:
    <table><tr><td>
    <pre>
    **Hello**,
    
    _world_.
    </pre>
    </td></tr></table>
  4. Switch to the Content Editor. The Content Editor should display this Markdown snippet.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #365292 (closed)

Edited by Enrique Alcántara

Merge request reports