Today I Was A Winner

I already knew that it made good sense to use simple macros to create references to other documents. For example, as I mentioned on the htm4l home page, I use a macro so that I can write this

m4_http(`www.teclata.es/terry', `my homepage')

instead of this

<a href="http://www.teclata.es/terry">my homepage</a> .

Admittedly, it doesn't save me much in the way of typing, but it does look nice and it's easier to remember. In the back of my mind I also thought "Yeah and if html changes the way links are made, then I'll really be a winner". Actually, html doesn't have to change, but something else might that will make you happy that you used a macro.


Today I was minding my own business (literally) when Ana the wonder partner got off the phone and told me excitedly that we had a customer who wanted web pages FOR SURE and that all we had to do was provide them with a copy on "floppy disks" ("what the hell is a floppy disk?" I asked myself) TODAY and that, by the way, they didn't have a connection to the outside world. No problem, right?

The solution was to find out how <insert browser name here> allowed you to refer to a local file on a PC, put the html and image files onto disks, and ship them the lot.


I soon realized that I would have to change the form of over 600 URLs. Instead of prefixing links with http://www.teclata.es I needed to prefix them with file///C| to satisfy the PC version of my browser. Using htm4l, this was completely trivial: I just altered the macros that create links and typed "make" and away it went. Then I did the same thing for images and 90% of the battle was won.

Not too impressive so far, I could have used a single perl command for all that. The thing that really made me laugh on the way to lunch was the following.

When I went to look at the pages on the browser on my PC, I could see some just fine but others not at all. The problem soon proved to be one with file names being too long. I was zipping up the UNIX files and zip was correctly truncating their names so they could be stored on the DOS-based machine. So all my nice descriptive file names in my links weren't being resolved.

Again the solution proved trivial, thanks to htm4l. I just chaged the macro that generates the link name from this

define(`m4_dq_http', `m4_http(`$1', `ENG_SPA(`$2', `$3')')')

to this

define(`m4_dq_http', `m4_http(`substr(`$1', 0, 8)', `ENG_SPA(`$2', `$3')')') .

I also changed the macro that tacks on the .html to instead add only .htm. As a result, all my links were genererated using only the first 8 chars of the filenames mentioned in the .htm4l files, and they had .htm just like my PC wanted. Did I say how much I hate PC's yet??? (You can follow this link to see what the ENG_SPA English/Spanish macro does if you're curious.)

So instead of getting output that looked like this

<a href="http://www.teclata.es/terry/a-long-file-name.html">XXX</a>

I got output that looked like this

<a href="file:///C|/terry/a-long-f.htm">XXX</a> .

Which was enough to solve everything. I typed "make" again and the pages with their 600 links were generated in about ten seconds and I went to lunch laughing like a crazy man.

If you can't do things like this with the tools you currently use to produce html, then one day you're probably going to wish you could. Htm4l isn't more powerful than using a perl-based system to produce html, it's probably not as simple as some other systems, but it is pretty good at getting some things done. The main point is to save your brain and fingers from pain. Even everyday html-production tasks can be greatly simplified, made faster and more consistent with htm4l (or a similar tool). You should use one. An experience like this one today makes me walk around smiling for hours, and I know I'm doing at least some things right.

Plus, it got me a job.


Back to the htm4l home page. Back to the htm4l examples page.
© Terry Jones (terry <AT> jon.es). Last modified: Mon Oct 2 02:21:32 CEST 2006