Although it hasn’t been updated in quite a long time, I still use the Pastacode plugin as I have found it to be the easiest to use and has the nicest display of all the others I have tried.
David, within the Visual editor try just pasting in the HTML without the <code> tags. Then highlight the code block and hit the Code button. Doing it this way should escape the HTML first.
Awesome π the TinyMCE can be a little fickle at times.
If you’re gonna be doing complex codes that may need updating, and don’t mind the extra request then embed a Gist or a Codepen. You can then update the code in a decent code editor π