BBCode Destroyer für Serendipity
Um möglichst alle Serendipity-User erreichen zu können, ist dieser Artikel in Englisch.
I have recently updated my Serendipity installation from the 0.7 series to 0.8 final. I was pretty surprised when I found out that the new BBCode parser wouldn't recognize URLs having characters like "!", "~" or "?" as valid anymore and therefore show BBCode in your entries instead of a link. This is especially ugly if your blog has, say, 300 entries and even those written years ago get broken.
Therefore I decided to stop using the BBCode parser and instead write my links and formatting (like bold, italic etc.) in plain HTML. But I didn't want to go through all of my 240 entries manually. So I wrote a dirty (but working) little script with the following features:
- replace tags like [b], [u], [img] and [url] with their XHTML equivalents
- possibility to easily modify the replacements and add new ones or delete those you don't like
- preview of changes before applying them to your database
- possibility to get rid of the NL2BR plugin as well by replacing newlines with "<br/>" tags and creating "<p>" tags around paragraphs (recognized by the one or more empty lines around them)
- the "newline" feature acts carefully by not touching entries already having "<p>" tags inside them or starting with stuff like "<ul>" or "<div>", but tells you that you need to change them manually
- no extra configuration needed because your local s9y config file is used
The script is not quite perfect because except for the customization nothing is commented in the code. Also it doesn't edit the "extended" part of an entry. But I used it for my blog and it definitely worked quite fine.
How to use it:
- get the script: BBCode Destroyer
- save it inside your s9y path (where serendipity_config_local.inc.php is located), call it something like
nobbcode.php - edit the settings at the top of the script file (if you want to, this is optional, the script works fine without)
- call it via your web browser (if your blog is at
http://scytale.de/blog/, the script is athttp://scytale.de/blog/nobbcode.php) - check what it wants to do, and if it's okay, click the link at the top
- manually edit the stuff it couldn't change automatically
If you have any questions concerning the script, feel free to post a comment. Saying "thank you" is considered nice as well. ;)
