3 .\" A simple set of macros to provide HTML documents with basic
4 .\" www functionality. It should work with any macro set.
10 .if '\*[.T]'html' .nr www-html 1
12 .\" set up www-image-template
13 .\" (cannot do this in html.tmac as the image device must
14 .\" also know about this string)
16 .if !d www-image-template \
17 . ds www-image-template
20 . \" remove the title command when we are generating images for html
21 . \" (stops a title accidentally appearing inside an image)
31 . tm \\n[.F]:\\n[.c]: macro error: \\$*
34 .\" the main auxiliary macro for the HTML interface
37 . if \\n[www-html] \{\
38 . \" the following line makes the vertical mode leave, so to say
46 .\" Automatic heading level cut off.
48 .\" N is the depth limit of automatically linked headings. So a depth
49 .\" of 2 would cause grohtml to generate a list of links for `.NH 1' and
50 .\" `.NH 2' but not for `.NH 3'.
57 .\" BCL foreground background active not-visited visited
60 . HTML <body text=\\$1 bgcolor=\\$2 link=\\$3 alink=\\$4 vlink=\\$5>
66 . HTML <body background=\\$1>
69 .\" URL url description [after]
73 . HTML <a href="\\$1">\\$2</a>\\$3
75 . nop \m[blue]\\$2\mP \%\[la]\fC\\$1\fP\[ra]\\$3
78 .\" FTP url description [after]
84 .\" MTO address description [after]
86 .\" ADDRESS is the email address (without the `mailto:' prefix).
88 .\" DESCRIPTION is the optional name. If an empty argument is given,
89 .\" ADDRESS is used instead.
91 .\" AFTER is optional stuff printed immediately after ADDRESS
92 .\" (resp. DESCRIPTION).
96 .\" Foobar has been written by
97 .\" .MTO fred@foo.bar "Fredrick Bloggs" .
100 . ie \\n[www-html] \{\
102 . URL mailto:\\$1 \\$1 "\\$3"
104 . URL mailto:\\$1 "\\$2" "\\$3"
108 . nop \%\m[blue]\fC\\$1\fP\mP\\$3
110 . nop \m[blue]\\$2\mP \%\[la]\fC\\$1\fP\[ra]\\$3
116 .\" Generate an html name NAME.
119 . HTML <a name="\\$1"></a>
122 .\" IMG [-R|-L|-C] filename [width] [height]
124 .\" Include an image of any type (will only work for -Thtml).
126 .\" Alignment is centered by default (-C).
127 .\" Default value for WIDTH is 1i.
128 .\" If HEIGHT is not given, WIDTH is used as the height.
131 . ie \\n[www-html] \{\
133 . HTML-TAG ".right-image"
136 . HTML-TAG ".left-image"
138 . HTML-TAG ".centered-image"
143 . nr www-height \\n[www-width]
146 . HTML <img src="\\$1" width=\\n[www-width] height=\\n[www-height]>
149 . nop \[la]\fC\\$1\fP\[ra]
154 .\" Emit a tag for grohtml. This is an internal macro.
157 . if \\n[www-html] \{\
158 . \" the following line makes the vertical mode leave, so to say
160 . nop \X^html-tag:\\$*^
164 .\" PIMG [-R|-L|-C] filename [width] [height]
166 .\" Include a png image. It will work for -Tps and -Thtml.
167 .\" The default value for WIDTH and HEIGHT is zero; the default
168 .\" alignment is centering (-C).
170 .\" Note: This macro can only be used with the `-U' option of groff,
171 .\" activating unsafe mode, if not used with -Thtml; the PNG image
172 .\" is then converted to the EPS format using netpbm utilities.
175 . ie \\n[www-html] \{\
177 . HTML-TAG ".right-image"
180 . HTML-TAG ".left-image"
182 . HTML-TAG ".centered-image"
187 . nr www-width (\\$3 * 100 / 240)
189 . nr www-height (\\$4 * 100 / 240)
190 . ie (\\n[www-width] == 0) \{\
191 . ie (\\n[www-height] == 0) \
192 . HTML <img src="\\$2">
194 . HTML <img src="\\$1" height=\\n[www-height]>
197 . ie (\\n[www-height] == 0) \
198 . HTML <img src="\\$2" width=\\n[www-width]>
200 . HTML <img src="\\$2" width=\\n[www-width] height=\\n[www-height]>
205 . www-make-unique-name
206 . sy pngtopnm \\$2 | pnmcrop -white | pnmtops -noturn > \\*[www-unique-name].eps
207 . PSPIC \\$1 \\*[www-unique-name].eps \\$3 \\$4
212 .nr www-left-ll-trap 0
213 .nr www-left-po-trap 0
214 .nr www-right-ll-trap 0
216 .de www-finish-left-po
217 . po -\\n[www-left-indent]u
218 . wh \\n[www-left-po-trap]u
219 . nr www-left-indent 0
222 .de www-finish-right-ll
223 . ll +\\n[www-right-indent]u
224 . \" now see whether we need to inline www-finish-left-ll
225 . if (\\n[www-left-ll-trap]u > 0) \
226 . if ((\\n[www-right-ll-trap]u + 1v) >= \\n[www-left-ll-trap]u) \{\
227 . mk www-left-po-trap
228 . nr www-left-po-trap +1v
229 . wh \\n[www-left-po-trap]u www-finish-left-po
230 . ll +\\n[www-left-indent]u
231 . wh \\n[www-left-ll-trap]u
232 . nr www-left-ll-trap 0
234 . \" and see whether we need to inline www-finish-left-po
235 . if (\\n[www-left-po-trap]u > 0) \
236 . if ((\\n[www-right-ll-trap]u + 1v) >= \\n[www-left-po-trap]u) \{\
237 . po -\\n[www-left-indent]u
238 . wh \\n[www-left-po-trap]u
239 . nr www-left-indent 0
241 . wh \\n[www-right-ll-trap]u
242 . nr www-right-ll-trap 0
245 .de www-finish-left-ll
246 . if (\\n[www-right-ll-trap] > 0) \
247 . if ((\\n[www-left-ll-trap] + 1v) >= \\n[www-right-ll-trap]) \{\
248 . ll +\\n[www-right-indent]u
249 . nr www-right-ll-trap 0
251 . mk www-left-po-trap
252 . nr www-left-po-trap +1v
253 . wh \\n[www-left-po-trap]u www-finish-left-po
254 . ll +\\n[www-left-indent]u
255 . wh \\n[www-left-ll-trap]u
256 . nr www-left-ll-trap 0
259 .\" MPIMG [-R|-L] filename [width] [height]
261 .\" Include a png image and wrap text around it. It will work for
262 .\" -Tps and -Thtml. The default value for WIDTH is 1i; default value
263 .\" for HEIGHT is WIDTH; the default alignment is left (-L).
265 .\" Note: This macro can only be used with the `-U' option of groff,
266 .\" activating unsafe mode, if not used with -Thtml; the PNG image
267 .\" is then converted to the EPS format using netpbm utilities.
273 . nr www-height \\n[www-width]
276 . nr www-width (\\n[www-width] * 100 / 240)
277 . nr www-height (\\n[www-height] * 100 / 240)
278 . ie \\n[www-html] \{\
280 . HTML <img src="\\$2" align=right width=\\n[www-width] height=\\n[www-height]>
282 . HTML <img src="\\$2" align=left width=\\n[www-width] height=\\n[www-height]>
286 . www-make-unique-name
287 . sy pngtopnm \\$2 | pnmcrop -white | pnmtops -noturn > \\*[www-unique-name].eps
289 . \" we must now disable a possible left image trap
291 . if (\\n[www-left-ll-trap] > 0) \
292 . wh \\n[www-left-ll-trap]u
293 . if (\\n[www-left-po-trap] > 0) \
294 . wh \\n[www-left-po-trap]u
295 . PSPIC -R \\*[www-unique-name].eps \\$3 \\$4
297 . nr www-right-indent \\n[ps-deswid]u
298 . ll -\\n[www-right-indent]u
299 . mk www-right-ll-trap
300 . nr www-right-ll-trap +(\\n[ps-desht]u - 1v)
301 . wh \\n[www-right-ll-trap]u www-finish-right-ll
302 . \" now restore possible left trap
303 . if (\\n[www-left-ll-trap] > 0) \
304 . wh \\n[www-left-ll-trap]u www-finish-left-ll
305 . if (\\n[www-left-po-trap] > 0) \
306 . wh \\n[www-left-po-trap]u
309 . \" we must now disable a possible right image trap
310 . if (\\n[www-right-ll-trap] > 0) \
311 . wh \\n[www-right-ll-trap]u
312 . PSPIC -L \\*[www-unique-name].eps \\$3 \\$4
314 . nr www-left-indent \\n[ps-deswid]u
315 . po +\\n[www-left-indent]u
316 . ll -\\n[www-left-indent]u
317 . mk www-left-ll-trap
318 . nr www-left-ll-trap +(\\n[ps-desht]u - 1v)
319 . wh \\n[www-left-ll-trap]u www-finish-left-ll
320 . \" now restore possible right trap
321 . if (\\n[www-right-ll-trap] > 0) \
322 . wh \\n[www-right-ll-trap]u www-finish-right-ll
330 .\" Begin heading. Heading level is N.
336 .\" If your heading contains URL, FTP, MTO macros you might wish to
337 .\" disable automatic links to headings. This can be done via `-P-l'
338 .\" from the command line or by using a cakk to `.HX 0'.
340 .nr www-heading-no -1
344 . nr www-heading-no 1
346 . nr www-heading-no \\$1
347 . HTML-TAG ".NH \\n[www-heading-no]"
351 . if (\\n[www-heading-no] == -1) \
352 . www-error "HnE found without a corresponding HnS"
358 .\" Emit the automatically collected links derived from
359 .\" section/numbered headings at this position.
367 .\" Produce a horizontal line
370 . ie \\n[www-html] \{\
380 .\" Suppresses the generation of the top and bottom rules which grohtml
381 .\" emits by default.
384 . HTML-TAG ".no-auto-rule"
387 .\" www-end-nowhere - end of input trap called to finish diversion.
395 .\" Generate an HTML title only. This differs from the -ms .TL macro
396 .\" which generates both an HTML title and a H1 heading.
398 .\" This is useful when an author wishes to use a HTML title as search
399 .\" engine fodder but a graphic title in the document.
401 .\" The macro terminates when a space or break is seen (.sp, .br).
404 . HTML-TAG ".html-tl"
405 . if !\\n[www-html] \{\
407 . it 2 www-end-nowhere
411 .ds www-level1 \[bu]\ \ \"
412 .ds www-level2 \[sq]\ \ \"
413 .ds www-level3 \[ci]\ \ \"
418 .\" Auxiliary macro for ULS.
422 . if (\\n[www-level] > 3) \
423 . www-error "too many levels of indentation (\\n[www-level])"
426 .\" Auxiliary macro for ULE.
429 . if !\\n[www-level] \
430 . www-error "trying to terminate a list which does not exist"
436 .\" Start an unordered list.
443 . if (\\n[www-level] == 1) \
444 . nr www-depth \\n[.i]
445 . nr www-depth +\w'\\*[www-level\\n[www-level]]'u
451 .\" End an unordered list.
457 . nr www-depth -\w'\\*[www-level\\n[www-level]]'u
465 .\" Insert a list item.
472 . ti -\w'\\*[www-level\\n[www-level]]'u
473 . nop \\*[www-level\\n[www-level]]\c
477 .\" DC l text [color]
479 .\" L is the letter to be dropped and enlarged.
481 .\" TEXT is the following text whose height the first letter should not
484 .\" COLOR is the optional color of the dropped letter (default black).
487 . ds www-dropcolor black
489 . ds www-dropcolor \\$3
490 . ie '\*(.T'html' \{\
491 . www-make-unique-name
492 . MPIMG -L \\*[www-unique-name].png "(\\n[.v] * 2u)"
496 . www-make-unique-name
497 . nop \O[3]\O[5i\\*[www-unique-name].png]\O[0]\O[1]
498 . nop \\m[\\*[www-dropcolor]]\\s[40]\\$1\\s0
499 . nop \O[2]\O[1]\O[4]
502 . nr dummy \\w'\\$1'u
503 . nr dcht ((\\n[.v] + \\n[rst]) * \\n[.ps] / \\n[rst])
504 . char \[dcap] \\m[\\*[www-dropcolor]]\\s'\\n[dcht]u'\\$1\\s0
505 . nop \\v'\\n[.v]u'\\[dcap]\\v'-\\n[.v]u'\c
512 .\" now set up TS, TE, EQ, EN default macros
514 .do if !d TS .do ds TS HTML-IMAGE
515 .do if !d TE .do ds TE HTML-IMAGE-END
516 .do if !d EQ .do ds EQ HTML-IMAGE
517 .do if !d EN .do ds EN HTML-IMAGE-END
519 .\" supplementary macros used by other macro sets
521 .\" here are some tags specially for -Tps or -Thtml when invoked by pre-html
522 .\" to generate png images from postscript.
524 .\" HTML-DO-IMAGE - tells troff to issue an image marker which can be
525 .\" read back by pre-html
529 . nop \O[3]\O[5\\$2\\$1.png]\O[0]\O[1]
531 . nop \O[3]\O[5\\$2\\$1.png]\O[0]
534 .\" HTML-IMAGE-END - terminates an image for html
538 . nop \O[2]\O[1]\O[4]
540 . nop \O[2]\O[1]\O[4]
546 .\" www-make-unique-name - generates another unique name in string
547 .\" `www-unique-name'
549 .de www-make-unique-name
551 . ds www-unique-name \\*[www-image-template]\\n[www-png-no]
554 .\" HTML-IMAGE and friends tell grohtml that this region of text needs
555 .\" to be rendered as an image.
558 . \" generates a centered image
559 . www-make-unique-name
560 . HTML-DO-IMAGE \\*[www-unique-name] c
564 . www-make-unique-name
565 . HTML-DO-IMAGE \\*[www-unique-name] r
569 . www-make-unique-name
570 . HTML-DO-IMAGE \\*[www-unique-name] l
573 .de HTML-IMAGE-INLINE
574 . www-make-unique-name
575 . HTML-DO-IMAGE \\*[www-unique-name] i