2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.