Question: why not try to use markdown code blocks?
Just surround your code in triple backticks: ` character.
Like this
```
here
is
```
An this is the actual raw markdown of my post: https://meta.discourse.org/raw/187974/3
---
You will have to educate your users, but this is your job as a moderator, plus it will help every user who has to deal with markdown later down the line.
You could do this by adding a new global pinned topic, something like "How to embed code on this site" or "How to type on this site".
You can also direct them to this link: [Markdown Reference (commonmark.org)](https://commonmark.org/help/)