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
44 .\" an auxiliary macro for HTML (without following space)
53 .\" Automatic heading level cut off.
55 .\" N is the depth limit of automatically linked headings. So a depth
56 .\" of 2 would cause grohtml to generate a list of links for `.NH 1' and
57 .\" `.NH 2' but not for `.NH 3'.
64 .\" BCL foreground background active not-visited visited
67 . HTML <body text=\\$1 bgcolor=\\$2 link=\\$3 alink=\\$4 vlink=\\$5>
73 . HTML <body background=\\$1>
76 .\" URL url description [after]
80 . HTML <a href="\\$1">\\$2</a>\\$3
82 . nop \m[blue]\\$2\m[] \%\[la]\f[C]\\$1\f[]\[ra]\\$3
85 .\" FTP url description [after]
91 .\" MTO address description [after]
93 .\" ADDRESS is the email address (without the `mailto:' prefix).
95 .\" DESCRIPTION is the optional name. If an empty argument is given,
96 .\" ADDRESS is used instead.
98 .\" AFTER is optional stuff printed immediately after ADDRESS
99 .\" (resp. DESCRIPTION).
103 .\" Foobar has been written by
104 .\" .MTO fred@foo.bar "Fredrick Bloggs" .
107 . ie \\n[www-html] \{\
109 . URL mailto:\\$1 \\$1 "\\$3"
111 . URL mailto:\\$1 "\\$2" "\\$3"
115 . nop \%\m[blue]\f[C]\\$1\f[]\m[]\\$3
117 . nop \m[blue]\\$2\m[] \%\[la]\f[C]\\$1\f[]\[ra]\\$3
123 .\" Generate an html name NAME.
126 . HTML <a name="\\$1"></a>
129 .\" IMG [-R|-L|-C] filename [width] [height]
131 .\" Include an image of any type (will only work for -Thtml).
133 .\" Alignment is centered by default (-C).
134 .\" Default value for WIDTH is 1i.
135 .\" If HEIGHT is not given, WIDTH is used as the height.
138 . ie \\n[www-html] \{\
140 . HTML-TAG ".right-image"
143 . HTML-TAG ".left-image"
145 . HTML-TAG ".centered-image"
150 . nr www-height \\n[www-width]
153 . HTML <img src="\\$1" width=\\n[www-width] height=\\n[www-height]>
156 . nop \[la]\f[C]\\$1\f[]\[ra]
161 .\" Emit a tag for grohtml. This is an internal macro.
164 . if \\n[www-html] \{\
165 . \" the following line makes the vertical mode leave, so to say
167 . nop \X^html-tag:\\$*^
173 .\" Emit a tag for grohtml (without a space). This is an internal macro.
177 . nop \X^html-tag:\\$*^\c
180 .\" PIMG [-R|-L|-C] filename [width] [height]
182 .\" Include a png image. It will work for -Tps and -Thtml.
183 .\" The default value for WIDTH and HEIGHT is zero; the default
184 .\" alignment is centering (-C).
186 .\" Note: This macro can only be used with the `-U' option of groff,
187 .\" activating unsafe mode, if not used with -Thtml; the PNG image
188 .\" is then converted to the EPS format using netpbm utilities.
191 . ie \\n[www-html] \{\
193 . HTML-TAG ".right-image"
196 . HTML-TAG ".left-image"
198 . HTML-TAG ".centered-image"
203 . nr www-width (\\$3 * 100 / 240)
205 . nr www-height (\\$4 * 100 / 240)
206 . ie (\\n[www-width] == 0) \{\
207 . ie (\\n[www-height] == 0) \
208 . HTML <img src="\\$2">
210 . HTML <img src="\\$1" height=\\n[www-height]>
213 . ie (\\n[www-height] == 0) \
214 . HTML <img src="\\$2" width=\\n[www-width]>
216 . HTML <img src="\\$2" width=\\n[www-width] height=\\n[www-height]>
221 . www-make-unique-name
222 . sy pngtopnm \\$2 | pnmcrop -white | pnmtops -noturn > \\*[www-unique-name].eps
224 . PSPIC \\*[www-unique-name].eps \\$3 \\$4
226 . PSPIC \\$1 \\*[www-unique-name].eps \\$3 \\$4
231 .nr www-left-ll-trap 0
232 .nr www-left-po-trap 0
233 .nr www-right-ll-trap 0
235 .de www-finish-left-po
236 . po -\\n[www-left-indent]u
237 . wh \\n[www-left-po-trap]u
238 . nr www-left-indent 0
241 .de www-finish-right-ll
242 . ll +\\n[www-right-indent]u
243 . \" now see whether we need to inline www-finish-left-ll
244 . if (\\n[www-left-ll-trap]u > 0) \
245 . if ((\\n[www-right-ll-trap]u + 1v) >= \\n[www-left-ll-trap]u) \{\
246 . mk www-left-po-trap
247 . nr www-left-po-trap +1v
248 . wh \\n[www-left-po-trap]u www-finish-left-po
249 . ll +\\n[www-left-indent]u
250 . wh \\n[www-left-ll-trap]u
251 . nr www-left-ll-trap 0
253 . \" and see whether we need to inline www-finish-left-po
254 . if (\\n[www-left-po-trap]u > 0) \
255 . if ((\\n[www-right-ll-trap]u + 1v) >= \\n[www-left-po-trap]u) \{\
256 . po -\\n[www-left-indent]u
257 . wh \\n[www-left-po-trap]u
258 . nr www-left-indent 0
260 . wh \\n[www-right-ll-trap]u
261 . nr www-right-ll-trap 0
264 .de www-finish-left-ll
265 . if (\\n[www-right-ll-trap] > 0) \
266 . if ((\\n[www-left-ll-trap] + 1v) >= \\n[www-right-ll-trap]) \{\
267 . ll +\\n[www-right-indent]u
268 . nr www-right-ll-trap 0
270 . mk www-left-po-trap
271 . nr www-left-po-trap +1v
272 . wh \\n[www-left-po-trap]u www-finish-left-po
273 . ll +\\n[www-left-indent]u
274 . wh \\n[www-left-ll-trap]u
275 . nr www-left-ll-trap 0
278 .\" MPIMG [-R|-L] filename [width] [height]
280 .\" Include a png image and wrap text around it. It will work for
281 .\" -Tps and -Thtml. The default value for WIDTH is 1i; default value
282 .\" for HEIGHT is WIDTH; the default alignment is left (-L).
284 .\" Note: This macro can only be used with the `-U' option of groff,
285 .\" activating unsafe mode, if not used with -Thtml; the PNG image
286 .\" is then converted to the EPS format using netpbm utilities.
292 . nr www-height \\n[www-width]
295 . nr www-width (\\n[www-width] * 100 / 240)
296 . nr www-height (\\n[www-height] * 100 / 240)
297 . ie \\n[www-html] \{\
299 . HTML <img src="\\$2" align=right width=\\n[www-width] height=\\n[www-height]>
301 . HTML <img src="\\$2" align=left width=\\n[www-width] height=\\n[www-height]>
305 . www-make-unique-name
306 . sy pngtopnm \\$2 | pnmcrop -white | pnmtops -noturn > \\*[www-unique-name].eps
308 . \" we must now disable a possible left image trap
310 . if (\\n[www-left-ll-trap] > 0) \
311 . wh \\n[www-left-ll-trap]u
312 . if (\\n[www-left-po-trap] > 0) \
313 . wh \\n[www-left-po-trap]u
314 . PSPIC -R \\*[www-unique-name].eps \\$3 \\$4
316 . nr www-right-indent \\n[ps-deswid]u
317 . ll -\\n[www-right-indent]u
318 . mk www-right-ll-trap
319 . nr www-right-ll-trap +(\\n[ps-desht]u - 1v)
320 . wh \\n[www-right-ll-trap]u www-finish-right-ll
321 . \" now restore possible left trap
322 . if (\\n[www-left-ll-trap] > 0) \
323 . wh \\n[www-left-ll-trap]u www-finish-left-ll
324 . if (\\n[www-left-po-trap] > 0) \
325 . wh \\n[www-left-po-trap]u
328 . \" we must now disable a possible right image trap
329 . if (\\n[www-right-ll-trap] > 0) \
330 . wh \\n[www-right-ll-trap]u
331 . PSPIC -L \\*[www-unique-name].eps \\$3 \\$4
333 . nr www-left-indent \\n[ps-deswid]u
334 . po +\\n[www-left-indent]u
335 . ll -\\n[www-left-indent]u
336 . mk www-left-ll-trap
337 . nr www-left-ll-trap +(\\n[ps-desht]u - 1v)
338 . wh \\n[www-left-ll-trap]u www-finish-left-ll
339 . \" now restore possible right trap
340 . if (\\n[www-right-ll-trap] > 0) \
341 . wh \\n[www-right-ll-trap]u www-finish-right-ll
349 .\" Begin heading. Heading level is N.
355 .\" If your heading contains URL, FTP, MTO macros you might wish to
356 .\" disable automatic links to headings. This can be done via `-P-l'
357 .\" from the command line or by using a cakk to `.HX 0'.
359 .nr www-heading-no -1
363 . nr www-heading-no 1
365 . nr www-heading-no \\$1
366 . HTML-TAG ".NH \\n[www-heading-no]"
370 . if (\\n[www-heading-no] == -1) \
371 . www-error "HnE found without a corresponding HnS"
377 .\" Emit the automatically collected links derived from
378 .\" section/numbered headings at this position.
386 .\" Produce a horizontal line
389 . ie \\n[www-html] \{\
399 .\" Suppresses the generation of the top and bottom rules which grohtml
400 .\" emits by default.
403 . HTML-TAG ".no-auto-rule"
406 .\" www-end-nowhere - end of input trap called to finish diversion.
414 .\" Generate an HTML title only. This differs from the -ms .TL macro
415 .\" which generates both an HTML title and a H1 heading.
417 .\" This is useful when an author wishes to use a HTML title as search
418 .\" engine fodder but a graphic title in the document.
420 .\" The macro terminates when a space or break is seen (.sp, .br).
423 . HTML-TAG ".html-tl"
424 . if !\\n[www-html] \{\
426 . it 2 www-end-nowhere
430 .ds www-level1 \[bu]\ \ \"
431 .ds www-level2 \[sq]\ \ \"
432 .ds www-level3 \[ci]\ \ \"
437 .\" Auxiliary macro for ULS.
441 . if (\\n[www-level] > 3) \
442 . www-error "too many levels of indentation (\\n[www-level])"
445 .\" Auxiliary macro for ULE.
448 . if !\\n[www-level] \
449 . www-error "trying to terminate a list which does not exist"
455 .\" Start an unordered list.
462 . if (\\n[www-level] == 1) \
463 . nr www-depth \\n[.i]
464 . nr www-depth +\w'\\*[www-level\\n[www-level]]'u
470 .\" End an unordered list.
476 . nr www-depth -\w'\\*[www-level\\n[www-level]]'u
484 .\" Insert a list item.
491 . ti -\w'\\*[www-level\\n[www-level]]'u
492 . nop \\*[www-level\\n[www-level]]\c
496 .\" DC l text [color]
498 .\" L is the letter to be dropped and enlarged.
500 .\" TEXT is the following text whose height the first letter should not
503 .\" COLOR is the optional color of the dropped letter (default black).
506 . ds www-dropcolor black
508 . ds www-dropcolor \\$3
509 . ie '\*(.T'html' \{\
510 . www-make-unique-name
511 . MPIMG -L \\*[www-unique-name].png "(\\n[.v] * 2u)"
515 . www-make-unique-name
516 . nop \O[5i\\*[www-unique-name].png]\O[1]
517 . nop \m[\\*[www-dropcolor]]\s[40]\O[3]\\$1\O[4]\s0\m[]
522 . nr dcht ((\\n[.v] + \\n[rst]) * \\n[.ps] / \\n[rst])
523 . char \[dcap] \m[\\*[www-dropcolor]]\s'\\n[dcht]u'\\$1
524 . nop \v'\\n[.v]u'\\[dcap]\v'-\\n[.v]u'\c
531 .\" now set up TS, TE, EQ, EN default macros
533 .do if !d TS .do ds TS HTML-IMAGE
534 .do if !d TE .do ds TE HTML-IMAGE-END
535 .do if !d EQ .do ds EQ HTML-IMAGE
536 .do if !d EN .do ds EN HTML-IMAGE-END
538 .\" supplementary macros used by other macro sets
540 .\" here are some tags specially for -Tps or -Thtml when invoked by pre-html
541 .\" to generate png images from postscript.
543 .\" HTML-DO-IMAGE - tells troff to issue an image marker which can be
544 .\" read back by pre-html
548 . nop \O[5\\$2\\$1.png]\O[1]\O[3]
550 . nop \O[5\\$2\\$1.png]\O[0]\O[3]
553 .\" HTML-IMAGE-END - terminates an image for html
557 . nop \O[4]\O[2]\O[0]
559 . nop \O[4]\O[2]\O[1]
565 .\" www-make-unique-name - generates another unique name in string
566 .\" `www-unique-name'
568 .de www-make-unique-name
570 . ds www-unique-name \\*[www-image-template]\\n[www-png-no]
573 .\" HTML-IMAGE and friends tell grohtml that this region of text needs
574 .\" to be rendered as an image.
577 . \" generates a centered image
578 . www-make-unique-name
579 . HTML-DO-IMAGE \\*[www-unique-name] c
583 . www-make-unique-name
584 . HTML-DO-IMAGE \\*[www-unique-name] r
588 . www-make-unique-name
589 . HTML-DO-IMAGE \\*[www-unique-name] l
592 .de HTML-IMAGE-INLINE
593 . www-make-unique-name
594 . HTML-DO-IMAGE \\*[www-unique-name] i
601 .if r ps4html .nop \O[0]