Friday, October 19, 2007

Edit Blog Post Seriously

Previously when I edit my blog posts, I rely on WYSIWYG editor provided by Blogger, and made minor tweaks if necessary.

When looking at the HTML code by clicking tab "Edit Html", I realized that the code generated is not what I desired. For example, it used tag <span> a lot with inline style to make font bold or italic, which violates basic HTML/CSS principle to separate content and display. It may also messy the structure of the post, which makes reading the HTML code rather painful.

In addition to the problems generated by the automatic tools, I now feel greater temptation to modify the HTML code by myself, e.g. using the nice tags (code, var, kbd, samp etc.) provided by HTML to describe source code in post, and also to make my post strictly conforming to XHTML standard.

Therefore I decided to use Emacs to edit blog posts. The bundled HTML mode is not satisfying, therefore I tried nXhtml mode instead. It is pretty good at the job: auto-completion of tags and attributes, validating the code on the fly, etc.

There are two settings needing modifications:

  • In "Settings/Basic" tab, select No for "Show Compose Mode for all your blogs?". The intention is to avoid Blogger to mess up the post when swithing between "Compose Mode" and "Edit Html" mode.
  • In "Settings/Formatting" tab, select No for "Convert line breaks". By selecting this, when you edit in Emacs, you can use <p>tag for paragraph, command M+Q to fill the paragraph, and the pasted code into Blogger would result in the same look as you previewed in Emacs. If this option is kept to "Yes", you have to manually tweak your code (remove <p> tag and also hard line breaks since Blogger will add line breaks in that case).

I also plans to rewrite my previous posts, seriously.

1 comment:

  1. Thanks for the tip! I've been greatly annoyed by the Blogger WYSIWYG editor for the same reasons, and have been wanting a better HTML mode in Emacs.

    ReplyDelete