Add groff 1.19.1, stripped down appropriately.
[dragonfly.git] / contrib / groff-1.19 / tmac / www.tmac
1 .ig
2 www.tmac - macro package for adding HTML elements to roff documents.
3
4 File position: <groff_source_top>/tmac/www.tmac
5 Installed position: groff's main macro directory.
6
7 ------------------------------------------------------------------------
8     Legalize
9 ------------------------------------------------------------------------
10
11 This file is part of groff, the GNU roff type-setting system.
12
13 Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
14 written by Gaius Mulley <gaius@glam.ac.uk>, with additions by
15 Werner Lemberg <wl@gnu.org> and Bernd Warken <bwarken@mayn.de>.
16
17 groff is free software; you can redistribute it and/or modify it under
18 the terms of the GNU General Public License as published by the Free
19 Software Foundation; either version 2, or (at your option) any later
20 version.
21
22 groff is distributed in the hope that it will be useful, but WITHOUT
23 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25 for more details.
26
27 You should have received a copy of the GNU General Public License
28 along with groff; see the file COPYING.  If not, write to the Free
29 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
30 02111-1307, USA.
31
32
33 ------------------------------------------------------------------------
34     Description
35 ------------------------------------------------------------------------
36
37 A simple set of macros to provide HTML documents with basic
38 www functionality.  It should work with any macro set.
39 ..
40 .
41 .\" --------------------------------------------------------------------
42 .\" Setup
43 .\" --------------------------------------------------------------------
44 .
45 .nr _C \n(.C
46 .cp 0
47 .
48 .nr www-html 0
49 .if '\*[.T]'html' .nr www-html 1
50 .
51 .\" set up www-image-template
52 .
53 .if !d www-image-template \
54 .  ds www-image-template
55 .
56 .if r ps4html \{\
57 .  \" remove the title command when we are generating images for html
58 .  \" (stops a title accidentally appearing inside an image)
59 .  di www-notitle
60 .  tl ''''
61 .  di
62 .  rm tl
63 .  de tl
64 .  .
65 .\}
66 .
67 .
68 .\" --------------------------------------------------------------------
69 .\" Test for `.substring'; result in register `www.substring_ok'.
70 .\" The automated break points in .URL addresses are only added if
71 .\" this register is non-zero.
72 .\"
73 .nr www:substring_ok 0
74 .de www:@test_substring
75 .  if !d substring \
76 .    return
77 .  ds \\$0:s abcdefg\"
78 .  substring \\$0:s 1 1
79 .  if !'\\*[\\$0:s]'b' \{\
80 .    rm \\$0:s
81 .    return
82 .  \}
83 .  ds \\$0:s abcdefg\"
84 .  substring \\$0:s 0 0
85 .  if !'\\*[\\$0:s]'a' \{\
86 .    rm \\$0:s
87 .    return
88 .  \}
89 .  ds \\$0:s abcdefg\"
90 .  substring \\$0:s 1 -1
91 .  if !'\\*[\\$0:s]'bcdefg' \{\
92 .    rm \\$0:s
93 .    return
94 .  \}
95 .  nr www:substring_ok 1
96 .  rm \\$0:s
97 ..
98 .www:@test_substring
99 .rm www:@test_substring
100 .
101 .
102 .\" --------------------------------------------------------------------
103 .\" Local Macros
104 .\" --------------------------------------------------------------------
105 .
106 .\" --------------------------------------------------------------------
107 .\" www:error (<test>...)
108 .\"
109 .\" Print error message
110 .\"
111 .de www-error
112 .  tm \\n[.F]:\\n[.c]: macro error: \\$*
113 ..
114 .als www:error www-error
115 .
116 .\" --------------------------------------------------------------------
117 .\" www:lenstr (<register_name> <string_name>)
118 .\"
119 .\" Store length of string named <string_name> into register named
120 .\" <register_name>.
121 .\"
122 .de www:lenstr
123 .  if !(\\n[.$] == 2) \{\
124 .    tm .\\$0 expects 2 arguments.
125 .    ab
126 .  \}
127 .  length \\$0:n x\\*[\\$2]
128 .  nr \\$1 (\\n[\\$0:n]-1)
129 .  rr \\$0:n
130 ..
131 .\" --------------------------------------------------------------------
132 .\" www:splitstr (<name>)
133 .\"
134 .\" Add a space character between any two adjacent characters in string
135 .\" <name> and restore result into the string variable <name>; space
136 .\" characters are first replaced by the word `space'.
137 .\"
138 .de www:splitstr
139 .  if !(\\n[.$] == 1) \
140 .    www:error .\\$0 expects 1 argument.
141 .  if '\\*[\\$1]'' \
142 .    return
143 .  ds \\$0:r "\\*[\\$1]\""
144 .  ds \\$0:s\"
145 .  while 1 \{\
146 .    ds \\$0:c "\\*[\\$0:r]\""
147 .    substring \\$0:c 0 0\"
148 .    ie '\\*[\\$0:c]' ' \
149 .      as \\$0:s " space\""
150 .    el \
151 .      as \\$0:s " \\*[\\$0:c]\""
152 .    www:lenstr \\$0:n \\$0:r
153 .    if (\\n[\\$0:n] <= 1) \{\
154 .      break
155 .    \}
156 .    substring \\$0:r 1 -1\"
157 .  \}
158 .  if !'\\*[\\$0:s]'' \
159 .    substring \\$0:s 1 -1 
160 .  ds \\$1 \\*[\\$0:s]
161 .  rm \\$0:c
162 .  rr \\$0:n
163 .  rm \\$0:r
164 .  rm \\$0:s
165 ..
166 .\" --------------------------------------------------------------------
167 .\" www:url_breaks (<string_name>)
168 .\"
169 .\" Add `\:' (possible break point) within URL strings after `/'.
170 .\"
171 .\" Smart about multiple `/', existing `\:', and space characters;
172 .\" does not set a break point if less than 5 characters would go to
173 .\" the next line.
174 .\"
175 .de www:url_breaks
176 .  if !(\\n[.$] == 1) \
177 .    www:error .\\$0 expects 1 argument.
178 .  if !\n[www:substring_ok] \
179 .    return
180 .  ds \\$0:s "\\*[\\$1]\""
181 .  www:splitstr \\$0:s
182 .  www:url_breaks_splitted \\$0:s \\*[\\$0:s]
183 .  ds \\$1 "\\*[\\$0:s]\""
184 .  rm \\$0:s
185 ..
186 .\" --------------------------------------------------------------------
187 .\" www:url_breaks_splitted (<result> <char> [<char>...])
188 .\"
189 .\" Add `\:' within URL strings, but arguments are a splitted string.
190 .\"
191 .\" Arguments: >=2: <result> <char> [<char>...]
192 .\"
193 .de www:url_breaks_splitted
194 .  nr \\$0:min 5             \" minimal number of characters for next line
195 .  if (\\n[.$] < 2) \
196 .    www:error .\\$0 expects at least 2 arguments.
197 .  ds \\$0:res \\$1\"
198 .  shift
199 .  ds \\$0:s\"
200 .  nr \\$0:done 0
201 .  while !\\n[\\$0:done] \{\
202 .    if (\\n[.$] <= 0) \{\
203 .      nr \\$0:done 1
204 .      break
205 .    \}
206 .    if '\\$1'space' \{\
207 .      as \\$0:s " \""
208 .      shift
209 .      continue
210 .    \}
211 .    if (\\n[.$] < \\n[\\$0:min]) \{\
212 .      as \\$0:s "\\$1\""
213 .      shift
214 .      continue
215 .    \}
216 .    if !'\\$1'/' \{\
217 .      as \\$0:s "\\$1\""
218 .      shift
219 .      continue
220 .    \}
221 .    \" we are at a `/' character
222 .    while '\\$1'/' \{\
223 .      as \\$0:s /\"
224 .      if (\\n[.$] == 0) \{\
225 .        nr \\$0:done 1
226 .        break
227 .      \}
228 .      shift
229 .    \}
230 .    if \\n[\\$0:done] \
231 .      break
232 .    if (\\n[.$] < \\n[\\$0:min]) \
233 .      continue
234 .    if '\\$1'\:' \
235 .      shift
236 .    as \\$0:s \:\"
237 .  \}
238 .  ds \\*[\\$0:res] \\*[\\$0:s]\"
239 .  rm \\$0:res
240 .  rm \\$0:s
241 ..
242 .\" --------------------------------------------------------------------
243 .\" User Interface
244 .\" --------------------------------------------------------------------
245 .
246 .\" --------------------------------------------------------------------
247 .\" HTML (<address> <description> [<punctuation>])
248 .\"
249 .\" the main auxiliary macro for the HTML interface
250 .\"
251 .de HTML
252 .  if \\n[www-html] \{\
253 .    \" the following line makes the vertical mode leave, so to say
254 .    nop \&
255 .    nop \X^html:\\$*^
256 .  \}
257 ..
258 .\"
259 .\" an auxiliary macro for HTML (without following space)
260 .\"
261 .de HTML-NS
262 .  if \\n[www-html] \
263 .    nop \X^html:\\$*^\c
264 ..
265 .\" --------------------------------------------------------------------
266 .\" HX n
267 .\"
268 .\"   Automatic heading level cut off.
269 .\"
270 .\"   N is the depth limit of automatically linked headings.  So a depth
271 .\"   of 2 would cause grohtml to generate a list of links for `.NH 1'
272 .\"   and `.NH 2' but not for `.NH 3'.
273 .\"
274 .de HX
275 .  if \\n[www-html] \
276 .    nop \X^index:\\$*^
277 ..
278 .\" --------------------------------------------------------------------
279 .\" BCL foreground background active not-visited visited
280 .\"
281 .de BCL
282 .  HTML <body text=\\$1 bgcolor=\\$2 link=\\$3 alink=\\$4 vlink=\\$5>
283 ..
284 .\" --------------------------------------------------------------------
285 .\" BGIMG imagefile
286 .\"
287 .de BGIMG
288 .  HTML <body background=\\$1>
289 ..
290 .\" --------------------------------------------------------------------
291 .\" URL url [description] [after]
292 .\"     if description is absent then the url becomes the anchor text
293 .\"
294 .de URL
295 .  ds \\$0:adr \\$1\"
296 .  www:url_breaks \\$0:adr
297 .  ie \\n[www-html] \{\
298 .    ie '\\$2'' \
299 .       HTML <a href="\\$1">\\$1</a>\\$3
300 .    el \
301 .       HTML <a href="\\$1">\\$2</a>\\$3
302 .  \}
303 .  el \{\
304 .    if !r ps4html .ad l
305 .    ie '\\$2'' \
306 .       nop \%\[la]\m[blue]\f[C]\\*[\\$0:adr]\f[]\m[]\[ra]\\$3
307 .    el \
308 .       nop \m[blue]\\$2\m[] \%\[la]\f[C]\\*[\\$0:adr]\f[]\[ra]\\$3
309 .    if !r ps4html .ad
310 .  \}
311 .  rm \\$0:adr
312 ..
313 .\" --------------------------------------------------------------------
314 .\" FTP url description [after]
315 .\"
316 .\"   Same as URL.
317 .\"
318 .als FTP URL
319 .\" --------------------------------------------------------------------
320 .\" MTO address description [after]
321 .\"
322 .\"   ADDRESS is the email address (without the `mailto:' prefix).
323 .\"
324 .\"   DESCRIPTION is the optional name.  If an empty argument is given,
325 .\"   ADDRESS is used instead.
326 .\"
327 .\"   AFTER is optional stuff printed immediately after ADDRESS
328 .\"   (resp. DESCRIPTION).
329 .\"
330 .\"     Example:
331 .\"
332 .\"       Foobar has been written by
333 .\"       .MTO fred@foo.bar "Fredrick Bloggs" .
334 .\"
335 .de MTO
336 .  ie \\n[www-html] \{\
337 .    ie '\\$2'' \
338 .      URL mailto:\\$1 \\$1 "\\$3"
339 .    el \
340 .      URL mailto:\\$1 "\\$2" "\\$3"
341 .  \}
342 .  el \{\
343 .    ie '\\$2'' \
344 .      nop \%\m[blue]\f[C]\\$1\f[]\m[]\\$3
345 .    el \
346 .      nop \m[blue]\\$2\m[] \%\[la]\f[C]\\$1\f[]\[ra]\\$3
347 .  \}
348 ..
349 .\" --------------------------------------------------------------------
350 .\" TAG name
351 .\"
352 .\"   Generate an html name NAME.
353 .\"
354 .de TAG
355 .  HTML <a name="\\$1"></a>
356 ..
357 .\" --------------------------------------------------------------------
358 .\" IMG [-R|-L|-C] filename [width] [height]
359 .\"
360 .\"   Include an image of any type (will only work for -Thtml).
361 .\"
362 .\"   Alignment is centered by default (-C).
363 .\"   Default value for WIDTH is 1i.
364 .\"   If HEIGHT is not given, WIDTH is used as the height.
365 .\"
366 .de IMG
367 .  ie \\n[www-html] \{\
368 .    ie '\\$2'-R' \
369 .      HTML-TAG ".right-image"
370 .    el \{\
371 .      ie '\\$2'-L' \
372 .        HTML-TAG ".left-image"
373 .      el \
374 .        HTML-TAG ".centered-image"
375 .    \}
376 .    nr www-width 100
377 .    if !'\\$3'' \
378 .      nr www-width \\$3
379 .    nr www-height \\n[www-width]
380 .    if !'\\$4'' \
381 .      nr www-height \\$4
382 .    HTML <img src="\\$1" width=\\n[www-width] height=\\n[www-height]>
383 .  \}
384 .  el \
385 .    nop \[la]\f[C]\\$1\f[]\[ra]
386 ..
387 .\" --------------------------------------------------------------------
388 .\" HTML-TAG
389 .\"
390 .\"   Emit a tag for grohtml.  This is an internal macro.
391 .\"
392 .de HTML-TAG
393 .  if \\n[www-html] \{\
394 .    \" the following line makes the vertical mode leave, so to say
395 .    nop \&
396 .    nop \X^html-tag:\\$*^
397 .  \}
398 ..
399 .\" --------------------------------------------------------------------
400 .\" HTML-TAG-NS
401 .\"
402 .\"   Emit a tag for grohtml (without a space).  This is an internal macro.
403 .\"
404 .de HTML-TAG-NS
405 .  if \\n[www-html] \
406 .    nop \X^html-tag:\\$*^\c
407 ..
408 .\" --------------------------------------------------------------------
409 .\" PIMG  [-R|-L|-C] filename [width] [height]
410 .\"
411 .\"   Include a png image.  It will work for -Tps and -Thtml.
412 .\"   The default value for WIDTH and HEIGHT is zero; the default
413 .\"   alignment is centering (-C).
414 .\"
415 .\" Note: This macro can only be used with the `-U' option of groff,
416 .\"       activating unsafe mode, if not used with -Thtml; the PNG image
417 .\"       is then converted to the EPS format using netpbm utilities.
418 .\"
419 .de PIMG
420 .  ie \\n[www-html] \{\
421 .    ie '\\$1'-R' \
422 .      HTML-TAG ".right-image"
423 .    el \{\
424 .      ie '\\$1'-L' \
425 .        HTML-TAG ".left-image"
426 .      el \
427 .        HTML-TAG ".centered-image"
428 .    \}
429 .    nr www-width 0
430 .    nr www-height 0
431 .    if !'\\$3'' \
432 .      nr www-width (\\$3 * 100 / 240)
433 .    if !'\\$4'' \
434 .      nr www-height (\\$4 * 100 / 240)
435 .    ie (\\n[www-width] == 0) \{\
436 .      ie (\\n[www-height] == 0) \
437 .        HTML <img src="\\$2">
438 .      el \
439 .        HTML <img src="\\$1" height=\\n[www-height]>
440 .    \}
441 .    el \{\
442 .      ie (\\n[www-height] == 0) \
443 .        HTML <img src="\\$2" width=\\n[www-width]>
444 .      el \
445 .        HTML <img src="\\$2" width=\\n[www-width] height=\\n[www-height]>
446 .    \}
447 .  \}
448 .  el \{\
449 .    if !r ps4html \{\
450 .      www-make-unique-name
451 .      sy pngtopnm \\$2 | pnmcrop -white | @PNMTOPS_NOSETPAGE@ -noturn > \\*[www-unique-name].eps
452 .      ie '\\$1'-C' \
453 .        PSPIC \\*[www-unique-name].eps \\$3 \\$4
454 .      el \
455 .        PSPIC \\$1 \\*[www-unique-name].eps \\$3 \\$4
456 .    \}
457 .  \}
458 ..
459 .
460 .\" --------------------------------------------------------------------
461 .\" auxiliary definitions for MPIMG
462 .\"
463 .nr www-left-ll-trap 0
464 .nr www-left-po-trap 0
465 .nr www-right-ll-trap 0
466 .
467 .de www-finish-left-po
468 .  po -(\\n[www-left-indent]u + \\n[www-image-gap]u)
469 .  wh \\n[www-left-po-trap]u
470 .  nr www-left-indent 0
471 ..
472 .
473 .\" called when the -R picture is finished
474 .de www-finish-right-ll
475 .  ll +(\\n[www-right-indent]u + \\n[www-image-gap]u)
476 .  \" now see whether we need to inline www-finish-left-ll
477 .  if (\\n[www-left-ll-trap]u > 0) \
478 .    if ((\\n[www-right-ll-trap]u + 1v) >= \\n[www-left-ll-trap]u) \{\
479 .      mk www-left-po-trap
480 .      nr www-left-po-trap +1v
481 .      wh \\n[www-left-po-trap]u www-finish-left-po
482 .      ll +\\n[www-left-indent]u
483 .      wh \\n[www-left-ll-trap]u
484 .      nr www-left-ll-trap 0
485 .    \}
486 .  \" and see whether we need to inline www-finish-left-po
487 .  if (\\n[www-left-po-trap]u > 0) \
488 .    if ((\\n[www-right-ll-trap]u + 1v) >= \\n[www-left-po-trap]u) \{\
489 .      po -\\n[www-left-indent]u
490 .      wh \\n[www-left-po-trap]u
491 .      nr www-left-indent 0
492 .    \}
493 .  wh \\n[www-right-ll-trap]u
494 .  nr www-right-ll-trap 0
495 ..
496 .
497 .de www-finish-left-ll
498 .  if (\\n[www-right-ll-trap] > 0) \
499 .    if ((\\n[www-left-ll-trap] + 1v) >= \\n[www-right-ll-trap]) \{\
500 .      ll +\\n[www-right-indent]u
501 .      nr www-right-ll-trap 0
502 .    \}
503 .  mk www-left-po-trap
504 .  nr www-left-po-trap +1v
505 .  wh \\n[www-left-po-trap]u www-finish-left-po
506 .  ll +(\\n[www-left-indent]u + \\n[www-image-gap]u)
507 .  wh \\n[www-left-ll-trap]u
508 .  nr www-left-ll-trap 0
509 ..
510 .\" --------------------------------------------------------------------
511 .\" MPIMG [-R|-L] [-G gap] filename [width [height]]
512 .\"
513 .\"   Include a png image and wrap text around it.  It will work for
514 .\"   -Tps and -Thtml.  The default value for WIDTH is 1i; default value
515 .\"   for HEIGHT is WIDTH; the default alignment is left (-L).
516 .\"   -G is used to insert a gap between the text and the image.
517 .\"
518 .\" Note: This macro can only be used with the `-U' option of groff,
519 .\"       activating unsafe mode, if not used with -Thtml; the PNG image
520 .\"       is then converted to the EPS format using netpbm utilities.
521 .\"
522 .
523 .nr www-htmlimage-gap 0
524 .
525 .de MPIMG
526 .  nr www-image-just 1
527 .  nr www-image-gap 0
528 .  while (\\n[.$] > 0) \{\
529 .    if '-L'\\$1' \{\
530 .      nr www-image-just 1
531 .      shift
532 .      continue
533 .    \}
534 .    if '-R'\\$1' \{\
535 .      nr www-image-just 0
536 .      shift
537 .      continue
538 .    \}
539 .    if '-G'\\$1' \{\
540 .      nr www-image-gap \\$2
541 .      nr www-htmlimage-gap (\\$2 * 100 / 240)
542 .      shift 2
543 .      continue
544 .    \}
545 .    break
546 .  \}
547 .  nr www-width 1i
548 .  if !'\\$2'' \
549 .    nr www-width \\$2
550 .  nr www-height \\n[www-width]
551 .  if !'\\$3'' \
552 .    nr www-height \\$3
553 .  nr www-width (\\n[www-width] * 100 / 240)
554 .  nr www-height (\\n[www-height] * 100 / 240)
555 .
556 .  ie \\n[www-html] \{\
557 .    ie !\\n[www-image-just] \
558 .      HTML <img src="\\$1" hspace=\\n[www-htmlimage-gap] \
559              align=right width=\\n[www-width] height=\\n[www-height]>
560 .    el \
561 .      HTML <img src="\\$1" hspace=\\n[www-htmlimage-gap] \
562              align=left width=\\n[www-width] height=\\n[www-height]>
563 .  \}
564 .  el \{\
565 .    if !r ps4html \{\
566 .      www-make-unique-name
567 .      sy pngtopnm \\$1 | pnmcrop -white | @PNMTOPS_NOSETPAGE@ -noturn > \\*[www-unique-name].eps
568 .      ie !\\n[www-image-just] \{\
569 .        \" we must now disable a possible left image trap
570 .        sp -1
571 .        if (\\n[www-left-ll-trap] > 0) \
572 .          wh \\n[www-left-ll-trap]u
573 .        if (\\n[www-left-po-trap] > 0) \
574 .          wh \\n[www-left-po-trap]u
575 .        PSPIC -R \\*[www-unique-name].eps \\$2 \\$3
576 .        sp -\\n[ps-desht]u
577 .        nr www-right-indent \\n[ps-deswid]u
578 .        \" we want to have some space between text and image,
579 .        \" so the line length must be shorter
580 .        ll -(\\n[www-right-indent]u + \\n[www-image-gap]u)
581 .        mk www-right-ll-trap
582 .        nr www-right-ll-trap +(\\n[ps-desht]u - 1v)
583 .        wh \\n[www-right-ll-trap]u www-finish-right-ll
584 .        \" now restore possible left trap
585 .        if (\\n[www-left-ll-trap] > 0) \
586 .          wh \\n[www-left-ll-trap]u www-finish-left-ll
587 .        if (\\n[www-left-po-trap] > 0) \
588 .          wh \\n[www-left-po-trap]u
589 .      \}
590 .      el \{\
591 .        \" we must now disable a possible right image trap
592 .        if (\\n[www-right-ll-trap] > 0) \
593 .          wh \\n[www-right-ll-trap]u
594 .        PSPIC -L \\*[www-unique-name].eps \\$2 \\$3
595 .        sp -\\n[ps-desht]u
596 .        nr www-left-indent \\n[ps-deswid]u
597 .        \" increase offset by gap
598 .        po +(\\n[www-left-indent]u + \\n[www-image-gap]u)
599 .        \" decrease line length by gap
600 .        ll -(\\n[www-left-indent]u + \\n[www-image-gap]u)
601 .        mk www-left-ll-trap
602 .        nr www-left-ll-trap +(\\n[ps-desht]u - 1v)
603 .        wh \\n[www-left-ll-trap]u www-finish-left-ll
604 .        \" now restore possible right trap
605 .        if (\\n[www-right-ll-trap] > 0) \
606 .          wh \\n[www-right-ll-trap]u www-finish-right-ll
607 .      \}
608 .    \}
609 .  \}
610 ..
611 .\" --------------------------------------------------------------------
612 .\" HnS n
613 .\"
614 .\"   Begin heading.  Heading level is N.
615 .\"
616 .\" HnE
617 .\"
618 .\"   End heading.
619 .\"
620 .\" If your heading contains URL, FTP, MTO macros you might wish to
621 .\" disable automatic links to headings.  This can be done via `-P-l'
622 .\" from the command line or by using a cakk to `.HX 0'.
623 .\"
624 .nr www-heading-no -1
625 .
626 .de HnS
627 .  ie '\\$1'' \
628 .    nr www-heading-no 1
629 .  el \
630 .    nr www-heading-no \\$1
631 .  HTML-TAG ".NH \\n[www-heading-no]"
632 ..
633 .
634 .de HnE
635 .  if (\\n[www-heading-no] == -1) \
636 .    www-error "HnE found without a corresponding HnS"
637 .  br
638 ..
639 .\" --------------------------------------------------------------------
640 .\" LK
641 .\"
642 .\"   Emit the automatically collected links derived from
643 .\"   section/numbered headings at this position.
644 .\"
645 .de LK
646 .  HTML-TAG ".links"
647 ..
648 .\" --------------------------------------------------------------------
649 .\" HR
650 .\"
651 .\"   Produce a horizontal line
652 .\"
653 .de HR
654 .  ie \\n[www-html] \{\
655 .    ti 0
656 .    HTML-NS <hr>
657 .  \}
658 .  el \
659 .    sp
660 ..
661 .\" --------------------------------------------------------------------
662 .\" NHR
663 .\"
664 .\"  Suppresses the generation of the top and bottom rules which grohtml
665 .\"  emits by default.
666 .\"
667 .de NHR
668 .  HTML-TAG ".no-auto-rule"
669 ..
670 .\"
671 .\" www-end-nowhere - end of input trap called to finish diversion.
672 .\"
673 .de www-end-nowhere
674 .  di
675 ..
676 .\" --------------------------------------------------------------------
677 .\" HTL
678 .\"
679 .\"   Generate an HTML title only.  This differs from the -ms .TL macro
680 .\"   which generates both an HTML title and a H1 heading.
681 .\"
682 .\"   This is useful when an author wishes to use a HTML title as search
683 .\"   engine fodder but a graphic title in the document.
684 .\"
685 .\"   The macro terminates when a space or break is seen (.sp, .br).
686 .\"
687 .de HTL
688 .  HTML-TAG ".html-tl"
689 .  if !\\n[www-html] \{\
690 .    di www-nowhere
691 .    it 2 www-end-nowhere
692 .  \}
693 ..
694 .
695 .\" --------------------------------------------------------------------
696 .\" auxiliary definitions for ULS / ULE
697 .\"
698 .ds www-level1 \[bu]\ \ \"
699 .ds www-level2 \[sq]\ \ \"
700 .ds www-level3 \[ci]\ \ \"
701 .nr www-level 0
702 .nr www-depth 0
703 .
704 .\"
705 .\" Auxiliary macro for ULS.
706 .\"
707 .de www-push-level
708 .  nr www-level +1
709 .  if (\\n[www-level] > 3) \
710 .    www-error "too many levels of indentation (\\n[www-level])"
711 ..
712 .\"
713 .\" Auxiliary macro for ULE.
714 .\"
715 .de www-pop-level
716 .  if !\\n[www-level] \
717 .    www-error "trying to terminate a list which does not exist"
718 .  nr www-level -1
719 ..
720 .\" --------------------------------------------------------------------
721 .\" ULS
722 .\"
723 .\"   Start an unordered list.
724 .\"
725 .de ULS
726 .  www-push-level
727 .  ie \\n[www-html] \
728 .    HTML "<ul>"
729 .  el \{\
730 .    if (\\n[www-level] == 1) \
731 .      nr www-depth \\n[.i]
732 .    nr www-depth +\w'\\*[www-level\\n[www-level]]'u
733 .  \}
734 ..
735 .\" --------------------------------------------------------------------
736 .\" ULE
737 .\"
738 .\"   End an unordered list.
739 .\"
740 .de ULE
741 .  ie \\n[www-html] \
742 .    HTML "</ul>"
743 .  el \{\
744 .    nr www-depth -\w'\\*[www-level\\n[www-level]]'u
745 .    in \\n[www-depth]u
746 .  \}
747 .  www-pop-level
748 ..
749 .\" --------------------------------------------------------------------
750 .\" LI
751 .\"
752 .\"   Insert a list item.
753 .\"
754 .de LI
755 .  ie \\n[www-html] \
756 .    HTML "<li>"
757 .  el \{\
758 .    in \\n[www-depth]u
759 .    ti -\w'\\*[www-level\\n[www-level]]'u
760 .    nop \\*[www-level\\n[www-level]]\c
761 .  \}
762 ..
763 .\" --------------------------------------------------------------------
764 .\" DC l text [color]
765 .\"
766 .\"   L is the letter to be dropped and enlarged.
767 .\"
768 .\"   TEXT is the following text whose height the first letter should not
769 .\"   exceed.
770 .\"
771 .\"   COLOR is the optional color of the dropped letter (default black).
772 .\"
773 .de DC
774 .  ds www-dropcolor black
775 .  if !'\\$3'' \
776 .    ds www-dropcolor \\$3
777 .  ie '\*(.T'html' \{\
778 .    www-make-unique-name
779 .    MPIMG -L \\*[www-unique-name].png "(\\n[.v] * 2u)"
780 .  \}
781 .  el \{\
782 .    ie r ps4html \{\
783 .      www-make-unique-name
784 .      \" To avoid interferences with another DC macro call which is located
785 .      \" very near to the current one, we draw the glyph on a separate page.
786 .      \" Otherwise it could theoretically happen that the dropped capital
787 .      \" glyphs overlap.
788 .      bp
789 .      ev www-DC
790 .      vs 80p
791 .      nop \O[5i\\*[www-unique-name].png]\O[1]
792 .      nop \m[\\*[www-dropcolor]]\s[40]\O[3]\\$1\O[4]
793 .      nop \O[2]\O[0]
794 .      br
795 .      ev
796 .      bp
797 .    \}
798 .    el \{\
799 .      ie n \
800 .        nop \\$1\c
801 .      el \{\
802 .        nr dummy \w'\\$1'u
803 .        nr dcht ((\\n[.v] + \\n[rst]) * \\n[.ps] / \\n[rst])
804 .        char \[dcap] \m[\\*[www-dropcolor]]\s'\\n[dcht]u'\\$1
805 .        nop \v'\\n[.v]u'\\[dcap]\v'-\\n[.v]u'\c
806 '        ti \w'\\[dcap]'u
807 .      \}
808 .    \}
809 .  \}
810 .  nop \\$2
811 ..
812 .\" --------------------------------------------------------------------
813 .\" Setup around HTML-IMAGE and friends
814 .\"
815 .\" now set up TS, TE, EQ, EN default macros
816 .\"
817 .do if !d TS .do ds TS HTML-IMAGE
818 .do if !d TE .do ds TE HTML-IMAGE-END
819 .do if !d EQ .do ds EQ HTML-IMAGE
820 .do if !d EN .do ds EN HTML-IMAGE-END
821 .\"
822 .\" supplementary macros used by other macro sets
823 .\"
824 .\" here are some tags specially for -Tps or -Thtml when invoked by
825 .\" pre-html to generate png images from postscript.
826 .
827 .\" --------------------------------------------------------------------
828 .\" HTML-DO-IMAGE - tells troff to issue an image marker which can be
829 .\"                 read back by pre-html
830 .\"
831 .de HTML-DO-IMAGE
832 .  if r ps4html \
833 .    nop \O[5\\$2\\$1.png]\O[1]\O[3]
834 .  if \\n[www-html] \
835 .    nop \O[5\\$2\\$1.png]\O[0]\O[3]
836 ..
837 .\" --------------------------------------------------------------------
838 .\" HTML-IMAGE-END - terminates an image for html
839 .\"
840 .de HTML-IMAGE-END
841 .  if r ps4html \
842 .    nop \O[4]\O[2]\O[0]
843 .  if \\n[www-html] \
844 .    nop \O[4]\O[2]\O[1]
845 ..
846 .
847 .nr www-png-no 0
848 .
849 .\" --------------------------------------------------------------------
850 .\" www-make-unique-name - generates another unique name in string
851 .\"                        `www-unique-name'
852 .\"
853 .de www-make-unique-name
854 .  nr www-png-no +1
855 .  ds www-unique-name \\*[www-image-template]\\n[www-png-no]
856 ..
857 .\" --------------------------------------------------------------------
858 .\" HTML-IMAGE and friends tell grohtml that this region of text needs
859 .\"            to be rendered as an image.
860 .\"
861 .de HTML-IMAGE
862 .  \" generates a centered image
863 .  www-make-unique-name
864 .  HTML-DO-IMAGE \\*[www-unique-name] c
865 ..
866 .
867 .de HTML-IMAGE-RIGHT
868 .  www-make-unique-name
869 .  HTML-DO-IMAGE \\*[www-unique-name] r
870 ..
871 .
872 .de HTML-IMAGE-LEFT
873 .  www-make-unique-name
874 .  HTML-DO-IMAGE \\*[www-unique-name] l
875 ..
876 .
877 .de HTML-IMAGE-INLINE
878 .  www-make-unique-name
879 .  HTML-DO-IMAGE \\*[www-unique-name] i
880 ..
881 .
882 .\" --------------------------------------------------------------------
883 .\" JOBNAME
884 .\"
885 .\"   Generate multiple output files containing the html.
886 .\"   A file is split whenever a .SH or .NH 1 is encountered.
887 .\"   The argument to JOBNAME is the file stem for future output files.
888 .\"
889 .de JOBNAME
890 .  HTML-TAG .job-name \\$1
891 ..
892 .\" --------------------------------------------------------------------
893 .\" Final Setup
894 .\" --------------------------------------------------------------------
895 .
896 .if \n[www-html] \{\
897 .   nh
898 .   nr HY 0
899 .\}
900 .
901 .\"
902 .\" start of some code
903 .\"
904 .
905 .de CDS
906 .ft C
907 .nf
908 ..
909 .\"
910 .\" end of some code
911 .\"
912 .
913 .de CDE
914 .fi
915 .ft P
916 ..
917 .
918 .if r ps4html .nop \O[0]
919 .cp \n(_C
920 .
921 .\" now set
922 .
923 .\" --------------------------------------------------------------------
924 .\" Emacs settings
925 .\" --------------------------------------------------------------------
926 .
927 .\" Local Variables:
928 .\" mode: nroff
929 .\" End:
930 .\" EOF