0

I'm using Wordpress 5.1 and Gutenberg block editor. I'm trying to show some Java code with the plugin SyntaxHighlighter Evolved. When editing a post I use the block 'Custom HTML' then add the code

[code language="java"]
List<Integer> myList = new ArrayList<>();
[/code]

Then I save the post and the Java code will appear correctly with syntax highlighting applied to it. It will look like this

enter image description here

This is the result that I wanted. But a problem happens when I edit the post again, in the Wordpress editing the Custom HTML block changes to the following

[code language="java"]
List&lt;Integer&gt; myList = new ArrayList&lt;&gt;();
[/code]

The < and > signs have been replaced by &lt; and &gt; and the code on the website becomes

enter image description here

Does anyone know how to fix this? thanks

  • 1
    Have you tried using the "SyntaxHighlighter Code" block? – Sally CJ Mar 4 at 12:59
  • 1
    @SallyCJ The SyntaxHighlighter block worked! Thanks a lot – area5one Mar 4 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.