Using the m4 language cleverly you can eliminate most of the tiresome repetitive work that is needed to build a complex Website. This
tutorial will take you through some uses of m4 for this purpose.
§ 6.1 Smart comments
With the following macro definition in place:
m4_define([m4_ignore],)
you can add comments to your m4 source code that do not appear in the
H.T.M.L. output. Conventional H.T.M.L. comments <!-- ... --> can
be viewed in a Web browser by selecting the View Source (Internet Explorer) or View Page Source (Mozilla Firefox) menu button.
Calls to the m4_ignore macro such as
m4_ignore(I do not show up in the H.T.M.L. code)
do not show up in the H.T.M.L. output and are therefore a safe place to
put comments that you don't want the users of your Web pages to read,
such as swear words and secret information.
The following macro call: m4_years(1973,06,17) prints out
the number of years elapsed since my date of birth, i.e. my age in
years.
§ 6.3 Questions and answers in the same source file
When writing Web tutorials (such as this one) it is useful to keep
your questions and the answers to those questions in a single source
file. In Question 6.15 you will write a macro ANSWER so that
answers are not visible in question pages but are visible in the
answer pages. For symmetry it is also useful to have a macro called
QUESTION so that your single source file can look something like
this:
QUESTION(1, What is George Bernard Shaw's middle name?)
ANSWER(1, Bernard)
QUESTION(2, How do you spell H.T.M.L.?)
ANSWER(2, H.T.M.L.)
QUESTION(3, What is the square root of 144?)
ANSWER(3, 12)
QUESTION(4, How many loaves are there in a baker's dozen?)
ANSWER(4, 13)
QUESTION(5, What is the meaning of life?)
ANSWER(5, 42)
§ 6.4 Two versions of your CV
By moving most of the code from your CV from cv.hts to cv.hts.m4
you can have two versions of your CV, once called cv.hts for your
Website, and another called cv-private.hts containing private
information and more suitable for printing than your public CV. Your
private CV can differ in the following ways from your public CV:
Your private CV can have information that you don't want to
appear on your public CV, such as your home address or other
information that is private to you.
Your private CV will not have the header and footer information
generated by m4_begin_html and m4_end_html so that it is more
suitable for printing out on a printer.
In your private CV you can safely define the PATCH_EMAIL
macro to do nothing, because your private CV will not a accessible by
the Internet. See Question 6.20 for this.