· topic

Quickly Edit HTML

These are some ideas on how to edit HTML quickly and efficiently, which is a continual problem for anyone like me who is always editing HTML. Sadly this doesn't really focus on any great solutions: this file is still being edited as a regular HTML file in emacs. Anyway, sections include:

Abbreviated XHTML

On the issue of whether it's better to author HTML by WYSIWYG or by using a Poor Man's Hypertext, I tend to flip-flop. I've recently written Mimulus, which is one of the former, and am now working on Avocet, which is one of the latter.

But in thinking that I'd like yet another directory to take some quick notes in, I realised that it would be rather nice to macroise some of the pains of XHTML, and yet to do so in a way that preserves the XML well-formedness. In other words, a kind of variant of XHTML which can be converted to XHTML 1.0 using a stylesheet.

For example, it'd be nice to do this:

<doc title="This Will Also be the h1!">
<stylesheet href="style.css"/>

<p>Hello there. This is a very simple <a 
<include ref="address"/>

It'd also enable one to use CDATA more freely, which would be rather a benefit when giving XML examples such as the one above! Perhaps the format could support CURIEs, too.

On conversion, it would become regular XHTML that can be validated with my xhtml.rnc, and it would be given a head/@profile so that the transformation could be two-way.

Another advantage is that the format itself could have a RELAX NG Compact schema, so it would be usable in nxml-mode.

Dynamic Templating

As I mention in the section on Abbreviated XHTML above, I often flip between lauding the WYSIWYG and Poor Man's Hypertext methods of editing; but in actual fact I tend to just edit HTML source. To aid that, I developed an XHTML RELAX NG Compact schema, xhtml.rnc, that I can use in nxml-mode in emacs. This points out errors for me as I go along, and provides some shortcuts for closing elements and so on.

But another thing that I do often is to use a kind of cut down form of HTML and then use a CGI to display that as HTML. This is the method that I use in Azimuth, the weblog engine that currently powers What Planet is This? and Strange Strands. Basically the format is:

Essay Title

<p>The content, as HTML, spanning
multiple lines.</p>

The title and h1 are derived from the first line, and the address and other appurtenances are added automatically. All this is done on the fly by the server, so in other words this format is the master format. This puts pressure on the server, of course, so it's not optimal.

Hence I'm trying out a new method. I'm using the format as above, with the extension of a <cdata> pseudo-element that acts a bit like the old <XMP> element in the very early HTMLs. But then, instead of having the server render the data, I use a wrapper around my normal text editor to do the conversion, so that it's baked instead of fried, or whatever that old metaphor was that Aaron invented and used for a while.

One problem with this is that I have to store files as *.txt in order to stop emacs from autodetecting them as XHTML for use with nXML.

Sean B. Palmer, 2006-11-21