Dotclear blog editing problem

The dotclear blogging engine has some issues when including pre-formated html; it removes all leading spaces and mangles empty lines.

This is a significant problem when posting nicely coloured code snippets like those produced by or the SyntaxHilighter in Wordpress.

A small hello world app ends up looking like this -

1public class Hello1
3public static void Main()
5System.Console.WriteLine("Hello, World!");

Instead of this -

1public class Hello1
3   public static void Main()
4   {
5      System.Console.WriteLine("Hello, World!");
6   }

Ahhh, much more readable. My way of solving this requires sed, so you’ll need a Linux installation, cygwin or Windows version of the command.

My CSS looks like this - border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;font-size:9px

Create a file called SedFixesForDotclear.sed. Its content is

1s/^$/<br/>/g #replace blank lines with <br/>
2s/t/    /g #replace tabs with spaces - then the next line replaces the spaces
3:l s/^((&nbsp)* ) /1&nbsp/;tl #replace all leading spaces with &nbsp

Run the command - sed -f SedFixesForDotclear.sed input.html > output.html

Paste the output file into your post.

comments powered by Disqus