Table of Content

technology01.pngWordPress is pretty good, but it comes with no code formatting tool, yet colouring facilities.
I like the simplicity of dp.SyntaxHighlighter for displaying source code in web pages: it works with major browsers and degrades fairly well.

Its particularity is that is does its painting magic on the client side. This can be a drawback in some instances, where the client browser has JavaScript disabled for instance, but since the code to paint is located within

###JavaScript###

###XML / HTML###

###PHP###

###SQL###

Last modified: Sunday, 18 April 2021

Author

Comments

Hi there… Thank you for your efforts 🙂 I tried using your modified plugin but still get ‘spaghetti’ code (everything in one line.) Is there a tag (like code or pre) I need to nest the textarea in (in the HTML view)? I tried everything with no luck… Thanks for the good work! 🙂

Hi Nik, there is no pre or code tag needed, only textarea. The modified version of the autoescape script I provide takes every occurence of the textarea tags and everything in=between and encodes it before WordPress has a chance to mess it up, then it decodes it before outputing it in the final page verbatim. My suggestions are: – make sure that you only use the default, non-rich-DHTML editor when writing posts in WordPress. – make sure you include the dp.SyntaxHighlighter script references in the right location in the header and footer of your wordpress theme templates (have a look at the source of this page to see where I put mine). – Make sure you install and activate in WordPress plugins my modified autoescape script. – Check that, in your posts stored in the MySQL database, any occurence of the textarea is actually encoded (should be long sequences of characters). If that still doesn’t work, it could be that your theme’s CSS messes up style for the textarea tag. If that’s the case, try to comment out any occurence of it in your CSS just to see if it has any effect. You could also try to make sure that the SyntaxHighlighter’s scripts are loaded after the definition for the theme’s CSS. Good luck!

I just realized that there were two places I could change or uncheck the “visual rich editor” option. One’s in the options tab (which is a global setting) and the other’s on the “My Account” page. I disabled the check box at the very bottom and voila! It works 🙂 Thanks a lot for your time 🙂 I’ve been switching my blog from MovableType to WordPress and am very (very) happy with the latter’s features and speed. Thanks again!

Thank you for this post, it helped me alot while trying to get code posting going on my blog.

Thanks a lot, this was just the solution I needed!

Nice work dude, I’m planning to add the syntaxhighlighter too, so I can finally stop worrying about my code 😛

Comments are closed.