Highlight.js removing line breaks from core/code block after update

117 views Asked by At

I am running highlight.js in the WordPress block editor and set highlight.js to run when core/code block is updated. The core/code block natively uses <br data-rich-text-line-break="true"> for it's line breaks. But when highlight.js runs it removes the line breaks.

Before:

enter image description here

enter image description here

After:

enter image description here

enter image description here

I tried using the highlight.js ignoreUnescapedHtML function:

//Define a custom function to exclude specific elements
hljs.configure({
ignoreUnescapedHTML: /<br\/?>/i, // Ignore <br> and <br/> tags
});

But could not get to work. https://highlightjs.readthedocs.io/en/latest/api.html

0

There are 0 answers