SemCodeFix: A plugin to display preformatted code in WordPress
SemCodeFix is a WordPress plugin I made to display preformatted code correctly. This plugin can display any type of code, html, text, scripts, etc. Using the plugin is easy, just wrap your text in a code tag from within the WordPress editor. Here’s an example of what it would look like. The code below is Python, its a solution to the Eight queens puzzle.
def n_queens(n, width):
if n == 0:
return [[]] # one solution, the empty list
else:
return add_queen(n-1, width, n_queens(n-1, width))
def add_queen(new_row, width, previous_solutions):
solutions = []
for sol in previous_solutions:
for new_col in range(width):
if safe_queen(new_row, new_col, sol):
solutions.append(sol + [new_col])
return solutions
def safe_queen(new_row, new_col, sol):
for row in range(new_row):
if (sol[row] == new_col or # same column clash
sol[row] + row == new_col + new_row or # diagonal clash
sol[row] - row == new_col - new_row): # other diagonal
return 0
return 1
for sol in n_queens(8, 8):
print sol
To activate/use this plugin, do the following:
1. Place the plugin file in the plugin directory of your WordPress installation and activate it.
2. Copy and paste the CSS into your local.css file of your theme’s directory.
3. Depending on your theme, your might want to change the width value in the div.code_child css style.
4. Any code you have, just wrap it in a code tag from within the editor.
When installed, the plugin will override the native code styles of your theme and display output as above.
Download the plugin file
Download the CSS file
Good luck


October 17th, 2006 at 8:50 am
Thanks for sharing! I have tried quite a few code plugins and this is the only one that worked for me.
December 12th, 2006 at 1:45 pm
What I want to do on my blog, is every few hours take the oldest post and move it to the
front of the queue, all automatically. Anyone know if there is a plugin that can do this or
a simple way to set up another plugin to do this (use my own feed perhaps)?
Thanks.
March 8th, 2007 at 7:18 pm
Great code! Thanks for that. I have one issue with it though and that is that my code doesn’t wrap. I have changed the width value in the div.code_child css file, but it doesn’t wrap it. Any tips to make this work? Thanks!
April 5th, 2007 at 5:20 am
Hi, thanks for the plugin. It works fine on my site, http://www.friendstergeek.com.
September 13th, 2007 at 1:54 pm
Thanks for making the plugin available; it worked perfectly for me.
October 7th, 2007 at 5:57 am
Hi!
Seems to be a nice plugin. I however does not got it to work fully. My \n is not displayed. Any idea how to fix this? They are visible when plugin is turned off.
http://www.jenst.se/2007/08/21/wordpress-create-own-more-tag
(Don’t care about the other code bugs, they are under control.)
October 7th, 2007 at 6:16 am
Hi again!
I solved my issue by installing preserve code formatting plugin instead. Thanks anyway!
December 28th, 2008 at 7:07 pm
This is a very lightweight plugin that just does what you need it to and nothing more. GREAT plugin!
However, I have found three things that it will not preserve, even when wrapped in code tags. These are:
& nbsp ;
& gt ;
& lt ;
(without the spaces of course)
I have tinkered around with the code for some time now and I was hoping you can let us know what needs to be adjusted in order to preserve those entities when they are wrapped in code tags.
Thanks a ton!
March 7th, 2009 at 3:17 am
great plugin, I use it on my html/php course blog
cheers
Tony
March 28th, 2009 at 8:06 pm
Thanks for this wonderful plugin. It does exactly what I needed ! Minified and great. Cheers.