HTML maintenance problems? Try M4!

Taken from newsgroups; not my page - Wolf Holzmann.
REFERENCES:   <3S0741$N21@CPCCUX0.CITYU.EDU.HK> <3S0FJG$GNH@NEWS.CAIS.COM>
ORGANIZATION: DATA I/O, REDMOND, WA
NEWSGROUPS:   COMP.INFOSYSTEMS.WWW.SERVERS.UNIX,COMP.INFOSYSTEMS.WWW.AUTHORING.HTML

In article <3s0fjg$gnh@news.cais.com> morrowc@his.com writes:
>eneric@cpccux0.cityu.edu.hk (LAU Kin Wai Eric) wrote:
>
>>Hi,
>>Any tools in the market available for creating home page under UNIX?
>>How can we get them?
>
>There is a product available from NAVISOFT...called navipress, it's in
>beta right now and frankly blows goatsm but maybe wen they finish it
>it'll be better...use VI or EMACS...they atleast work and are WASY as
>crap to use.

Use M4, the standard Unix macro expansion tool

M4 is the standard UNIX macro expansion facility. You can create compressed MACRO's of the things you would like to do and have it expand them.

For example you could create a Makefile rule such as:

.SUFFIXES : .m4 .html

 .m4.html :
         (umask 022;${M4} $< > $@)

An html include file such as:

define(`HEADER',`<html>
<head><title>$1</title></head>
<body>
<center>
<h1>$1</h1>
<h3>William S. England<br>
June 1995</h3>
</center>
<hr>
')dnl
define(`TRAILER',`<hr>
<h5>
<a href="/wecgi-bin/imagemap//menu.map">
<img src="/gif/menu.gif" alt="[Clickable map]" ISMAP></a><p>
<a href="/">Home Page</a> |
</h5>
</body>
</html>
')dnl

And then your source files could look like:

include(`htmldefs.m4')dnl
HEADER(`Information Distribution System<br>Software Requirements')dnl

<h2>Abstract</h2>

[...] Cut a bunch of stuff out.

define(`B_SHDR',`<a name="$1"><hr><h2>')dnl
define(`E_SHDR',`</h2></a>')dnl

B_HDR(`X11') _X11
E_SHDR

The X11 GUI system from MIT is either a standard package
or available as an option on almost every graphicly capable

[...] Cut a bunch more stuff out.

TRAILER

This lets you create standard headers and footers in one include file and then propagate the defaults throughout your documents with macros.

Works Great!

Less Redundancy!