What’s the deal with the <code> element in WordPress?
When I put source code in a <code> block in WordPress:
- It doesn’t preserve indentation. This is useless for Python code
- It doesn’t allow newlines in the block without starting a new <code> element.
- There’s no way to insert a <pre> or <code> block in the visual editor interface
I guess I should look around for a source-code syntax-highlighting plugin for WordPress? Anyone know of a good one?
August 26th, 2008 at 9:22 am
code is an inline element, so that behavior regarding newlines is correct.
Are you sure you can’t put a pre block in? Just type in <pre> manually in the HTML view of the editor.
What most people do is wrap the code in pre. See for example:
http://htmlhelp.com/reference/html40/phrase/code.html
August 26th, 2008 at 9:23 am
BTW, you need to escape the less-than and greater-than signs around the word code in the post title — this post looks really funny in a feed reader!