CKEditor5 setData() stripping <code> tags

Viewed 130

When I try to run

editor.setData("<p>test comment</p><code class=\"python-code\">def withCodeBlock:<br /> print('test')</code>");

The resulting editor contains the html:

<p>test comment</p>
<p>def withCodeBlock:
<br>print('test')</p>

It strips out the <code> tags, how can I stop this?

1 Answers

I found my issue, my sanitizer was removing a wrapping <pre> tag around the codeblock

editor.setData("<p>test comment</p><pre><code class=\"python-code\">def withCodeBlock:<br /> print('test')</code></pre>");

works perfect

Related