Mason Wheeler
Mason Wheeler

Reputation: 84650

How do I keep WordPress from formatting out leading spaces?

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?

Upvotes: 3

Views: 1223

Answers (2)

randomx
randomx

Reputation: 2377

Use the code editor (NOT Visual) and wrap your code in

<pre></pre> 

tags. Then format appropriately in your theme's CSS.

Here's Wordpress' explanation

Upvotes: 7

nickytonline
nickytonline

Reputation: 6981

I would use the FCKEditor (now called CKEditor) plugin, http://www.deanlee.cn/wordpress/fckeditor-for-wordpress-plugin/. I find it works a lot better than the built-in TinyMCE default editor. The only time I haven't used it is when I have sites that use the qTranslate plugin as it does not currently support CKEditor.

Upvotes: 1

Related Questions