On-the-fly conversion...

Philippe-Andre Prindeville (philipp@res.enst.fr)
Fri, 29 Dec 95 06:27:30 +0100


This is more a question about programming HTML converters than
about the protocol itself, so apologies in advance to anyone
offended by my cheek, but here goes...

I'm working on a converter that generates HTML as part of a
CGI script... Much of the parsing is character driver.
Occasionally, we see a sequence which means "start bold-italic"
(much like ".BI" in troff)... So we must either generate a
"<b><i>" or "<i><b>" sequence.

Yes, I know I should be using <em> and <strong>. Nevermind.

The question is this. After the "start bold-italic"
sequence, I must see a "start bold" sequence or a "start italic"
sequence. Obviously, <b><i>something</i> else</b> or
<i><b>yet</b> another</i> is preferrable to
<i><b>something</b></i> <b>else</b> or <b><i>yet</i></b> <i>another</i>
in terms of conciseness or parsability.

I currently just do the following on a wrapper in perl:

s/(<[bi]>)(</[bi]>)/$2$1/g;

but this is ugly.

Any better ideas?

Thanks,

-Philip