I’m trying to post some code snippets on my WordPress blog, but when I copy and paste, it strips out all the leading spaces from each line of code. It doesn’t seem to have a problem with leading spaces being there in general, since I can add them back in manually, but it doesn’t like them being pasted in for whatever reason.
Is there some plugin I can use, or some simple code modification I can make, to make it accept the code I paste in without trying to format it for me?
Use the code editor (NOT Visual) and wrap your code in
tags. Then format appropriately in your theme’s CSS.
Here’s WordPress’ explanation