Too Cool for Internet Explorer


Swobodin's Profile | Swobodin's Blog | Back to Fedora Tunisia

Writing valid XHTML posts on WordPress

WordPress contains a nice WYSIWYG HTML editor, but it doesn’t fit with XHTML specifications.
I found out a cool method to generate valid XHTML code on WordPress; all what you need is Nvu and Vim.
First, use Nvu to edit your HTML text, and set you markup output to XHTML transitional:
Tools - Preferences - Advanced - Markup: XHTML1 and Transitional.
Keep writing and decorating: Nvu is powerful doesn’t screw your code up!
Once you made a valid document, you have to convert it to WordPress format. First, backup the original HTML file (who knows?) and edit the copy with Vim. During all the process, you need to have the escape mode activated, just press <ESC>.
Put the cursor on the line that contains only <body> tag and type (sensitive case)
dgg
It will remove the lines from ‘body’ tag to the beginning.
The same, go to the line containing </body> and get rid of the end of the document:
dG
As Nvu wraps lines, we will convert the newlines into spaces:
:%s/\n/\ /g
Now, we will convert the XHTML breaklines (<br />) to carriage returns (and not newlines):
:%s/<br\ \/>\ /\r/g
:%s/<br\ \/>/\r/g
Next, convert the lines that contain more than one newline to spaces, otherwise, WordPress will put incorrect <p> tags
:%s/\n\{2\}/\r\&nbsp;\r\&nbsp;/g
Optionally, you can add a carriage return to some tags that are displayed by blocks by default such as <blockquote> :
:%s/\([^\^]\)\(<blockquote>\)/\1\r\2/g
But </blockquote> must be the last term at the end of the line:
:%s/\(<\/blockquote>\)\([^\$]\)/\1\r\2/g
Now you can check that your post is a valid XHTML, exactly the same for this blog!
 
 

Related posts

(sometimes, the plugin foolishes)
Firefox screws XHTML code up
Running PHP code on WordPress
Permanent links in WordPress
Fedora Tunisia Reloaded
DokuWiki

Technorati tags

One Response to “Writing valid XHTML posts on WordPress”

  1. Rumore » Blog Archive » Ma Says:

    […] Az hogy a farokba lehet hogy nem létezik bloggoló extension-je az NVU-nak? Ez lehetne a legállatabb blog kliens a föld kerekén… egy technorati search elég hozzá hogy lássuk: vannak emberek, akik ezt használják blogposzt íráshoz, de ez a kimásolós-bepasztálós módszer szerintem béna. Színtiszta XUL az egész, mibe kerülne ehhez is csinálni egy extension-t  - de ez még semmi - rájöttem hogy összességében alig van extension az NVU-hoz - és semmi sincs, ami értelmesebbé is tenné. Amúgy rosszul emlékszem, hogy ez valaha mozilla projekt volt? Vajon mi történhetett. És július óta frissítés sincs, hm… […]

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

 
 

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 5 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a


Top Tunisie Blogs