I face this issue quite often on my own site where I publish code tutorials. Unfortunately, there isn’t a good solution. Instead, I recommend this workflow:
- Use the WYSIWYG editor to build your article content leaving placeholders for your code snippets.
- Switch to the HTML editor to add your code snippets
The visual editor (TinyMCE) tries to escape code-like characters for display. It wasn’t meant for writing code snippets in the first place.