Menu

WordPress, Sourcecode, and escaping

May 5, 2012 - .NET, C#, General Computing, Programming

Every single time I write a post that contains source code, it’s a bloody struggle.

Take my previous “snippets” entry.

Normally, I draft it and plan it in advance, and use Editpad Pro on my windows machine to write it out. Now, in a ideal universe where stuff works properly, I would be able to just paste the code in without putting dumbass escapes- that’s what the CMS is supposed to do, manage my content- but no such luck. So, I replace all < with < and all > with > and all that drollish crap that people use software to avoid. It’s especially fun when the blog helpfully assumes I am using some secret tag when I use generics.

Anyway, first problem: well, some of my swapping was wrong. Second, everything was double-spaced thanks to the magic of me making the original textfile on a windows machine (crlf versus just cr).

I had to actually get the original source from the project I based the post on, perform the replacement, paste it into the proper tag, and hope the gods of blog software were smiling upon me.

Long story short- Putting code in posts is more painful than it should be. I sort of expected the add-in I use for highlighting and code blocks to have been smart enough to properly mark-up the text itself without intervention, but no such luck.

Have something to say about this post? Comment!

2 thoughts on “WordPress, Sourcecode, and escaping

Lanfranco Sal

This was precisely the answers I’d been searching for. Amazing blog. Incredibly inspirational! Your posts are so helpful and detailed. The links you feature are also very useful too. Thanks a lot 🙂

Niko Holmen

magnificent issues altogether, you just received a new reader. What may you recommend in regards to your submit that you simply made some days in the past? Any positive?

Comments are closed.