* src/roff/nroff/nroff.man: Document option `-M'.
[s-roff.git] / tmac / www.tmac
blobc0b6ed02aab6b991a3fe15cce3d88ee71d499b08
1 .ig
2 www.tmac - macro package for adding HTML elements to roff documents.
4 File position: <groff_source_top>/tmac/www.tmac
5 Installed position: groff's main macro directory.
7 ------------------------------------------------------------------------
8     Legalize
9 ------------------------------------------------------------------------
11 This file is part of groff, the GNU roff type-setting system.
13 Copyright (C) 2001, 2002, 2003, 2004, 2005 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>.
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.
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.
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.
33 ------------------------------------------------------------------------
34     Description
35 ------------------------------------------------------------------------
37 A simple set of macros to provide HTML documents with basic
38 www functionality.  It should work with any macro set.
41 .\" --------------------------------------------------------------------
42 .\" Setup
43 .\" --------------------------------------------------------------------
45 .do if d www:lenstr .nx
47 .do mso devtag.tmac
49 .nr _C \n(.C
50 .cp 0
53 .nr www-html 0
54 .if '\*[.T]'html' .nr www-html 1
56 .\" set up www-image-template
58 .if !d www-image-template \
59 .  ds www-image-template
61 .if r ps4html \{\
62 .  \" remove the title command when we are generating images for html
63 .  \" (stops a title accidentally appearing inside an image)
64 .  di www-notitle
65 .  tl ''''
66 .  di
67 .  rm tl
68 .  de tl
69 .  .
70 .\}
73 .\" --------------------------------------------------------------------
74 .\" Test for `.substring'; result in register `www.substring_ok'.
75 .\" The automated break points in .URL addresses are only added if
76 .\" this register is non-zero.
77 .\"
78 .nr www:substring_ok 0
79 .de www:@test_substring
80 .  if !d substring \
81 .    return
82 .  ds \\$0:s abcdefg\"
83 .  substring \\$0:s 1 1
84 .  if !'\\*[\\$0:s]'b' \{\
85 .    rm \\$0:s
86 .    return
87 .  \}
88 .  ds \\$0:s abcdefg\"
89 .  substring \\$0:s 0 0
90 .  if !'\\*[\\$0:s]'a' \{\
91 .    rm \\$0:s
92 .    return
93 .  \}
94 .  ds \\$0:s abcdefg\"
95 .  substring \\$0:s 1 -1
96 .  if !'\\*[\\$0:s]'bcdefg' \{\
97 .    rm \\$0:s
98 .    return
99 .  \}
100 .  nr www:substring_ok 1
101 .  rm \\$0:s
103 .www:@test_substring
104 .rm www:@test_substring
107 .\" --------------------------------------------------------------------
108 .\" Local Macros
109 .\" --------------------------------------------------------------------
111 .\" --------------------------------------------------------------------
112 .\" www:paraspace
114 .\" Space before paragraph. Use \n[PD] if it exists.
116 .nr www:pd 0.5v
117 .de www:paraspace
118 .  ie r PD .sp \\n[PD]u
119 .  el .sp \\n[www:pd]u
123 .\" --------------------------------------------------------------------
124 .\" www:error (<test>...)
126 .\" Print error message
128 .de www-error
129 .  tm \\n[.F]:\\n[.c]: macro error: \\$*
131 .als www:error www-error
133 .\" --------------------------------------------------------------------
134 .\" www:lenstr (<register_name> <string_name>)
136 .\" Store length of string named <string_name> into register named
137 .\" <register_name>.
139 .de www:lenstr
140 .  if !(\\n[.$] == 2) \{\
141 .    tm .\\$0 expects 2 arguments.
142 .    ab
143 .  \}
144 .  length \\$0:n x\\*[\\$2]
145 .  nr \\$1 (\\n[\\$0:n]-1)
146 .  rr \\$0:n
148 .\" --------------------------------------------------------------------
149 .\" www:splitstr (<name>)
151 .\" Add a space character between any two adjacent characters in string
152 .\" <name> and restore result into the string variable <name>; space
153 .\" characters are first replaced by the word `space'.
155 .de www:splitstr
156 .  if !(\\n[.$] == 1) \
157 .    www:error .\\$0 expects 1 argument.
158 .  if '\\*[\\$1]'' \
159 .    return
160 .  ds \\$0:r "\\*[\\$1]\""
161 .  ds \\$0:s\"
162 .  while 1 \{\
163 .    ds \\$0:c "\\*[\\$0:r]\""
164 .    substring \\$0:c 0 0\"
165 .    ie '\\*[\\$0:c]' ' \
166 .      as \\$0:s " space\""
167 .    el \
168 .      as \\$0:s " \\*[\\$0:c]\""
169 .    www:lenstr \\$0:n \\$0:r
170 .    if (\\n[\\$0:n] <= 1) \{\
171 .      break
172 .    \}
173 .    substring \\$0:r 1 -1\"
174 .  \}
175 .  if !'\\*[\\$0:s]'' \
176 .    substring \\$0:s 1 -1 
177 .  ds \\$1 \\*[\\$0:s]
178 .  rm \\$0:c
179 .  rr \\$0:n
180 .  rm \\$0:r
181 .  rm \\$0:s
183 .\" --------------------------------------------------------------------
184 .\" www:url_breaks (<string_name>)
186 .\" Add `\:' (possible break point) within URL strings after `/'.
188 .\" Smart about multiple `/', existing `\:', and space characters;
189 .\" does not set a break point if less than 5 characters would go to
190 .\" the next line.
192 .de www:url_breaks
193 .  if !(\\n[.$] == 1) \
194 .    www:error .\\$0 expects 1 argument.
195 .  if !\n[www:substring_ok] \
196 .    return
197 .  ds \\$0:s "\\*[\\$1]\""
198 .  www:splitstr \\$0:s
199 .  www:url_breaks_splitted \\$0:s \\*[\\$0:s]
200 .  ds \\$1 "\\*[\\$0:s]\""
201 .  rm \\$0:s
203 .\" --------------------------------------------------------------------
204 .\" www:url_breaks_splitted (<result> <char> [<char>...])
206 .\" Add `\:' within URL strings, but arguments are a splitted string.
208 .\" Arguments: >=2: <result> <char> [<char>...]
210 .de www:url_breaks_splitted
211 .  nr \\$0:min 5             \" minimal number of characters for next line
212 .  if (\\n[.$] < 2) \
213 .    www:error .\\$0 expects at least 2 arguments.
214 .  ds \\$0:res \\$1\"
215 .  shift
216 .  ds \\$0:s\"
217 .  nr \\$0:done 0
218 .  while !\\n[\\$0:done] \{\
219 .    if (\\n[.$] <= 0) \{\
220 .      nr \\$0:done 1
221 .      break
222 .    \}
223 .    if '\\$1'space' \{\
224 .      as \\$0:s " \""
225 .      shift
226 .      continue
227 .    \}
228 .    if (\\n[.$] < \\n[\\$0:min]) \{\
229 .      as \\$0:s "\\$1\""
230 .      shift
231 .      continue
232 .    \}
233 .    if !'\\$1'/' \{\
234 .      as \\$0:s "\\$1\""
235 .      shift
236 .      continue
237 .    \}
238 .    \" we are at a `/' character
239 .    while '\\$1'/' \{\
240 .      as \\$0:s /\"
241 .      if (\\n[.$] == 0) \{\
242 .        nr \\$0:done 1
243 .        break
244 .      \}
245 .      shift
246 .    \}
247 .    if \\n[\\$0:done] \
248 .      break
249 .    if (\\n[.$] < \\n[\\$0:min]) \
250 .      continue
251 .    if '\\$1'\:' \
252 .      shift
253 .    as \\$0:s \:\"
254 .  \}
255 .  ds \\*[\\$0:res] \\*[\\$0:s]\"
256 .  rm \\$0:res
257 .  rm \\$0:s
259 .\" --------------------------------------------------------------------
260 .\" User Interface
261 .\" --------------------------------------------------------------------
263 .\" --------------------------------------------------------------------
264 .\" HTML
266 .\" the main auxiliary macro for the HTML interface
268 .de HTML
269 .  if \\n[www-html] \{\
270 .    \" was implemented via .nop \&\X^html:\\$*^ but
271 .    \" is now implemented using HTML-NS to utilize code factoring.
272 .    \"
273 .    \" the `\&' makes the vertical mode leave, so to say
274 .    \"
275 .    nop \&\c
276 .    HTML-NS \\$*
277 .    nop \&
278 .  \}
281 .\" an auxiliary macro for HTML (without following space)
283 .de HTML-NS
284 .  nop \X^html:\\$*^\c
287 .\" emit a HTML tag after shutting down a (possibly open) paragraph
289 .de HTML</p>
290 .  if \\n[www-html] \{\
291 .    \" the `\&' makes the vertical mode leave, so to say
292 .    nop \&\X^html</p>:\\$*^
293 .  \}
295 .\" --------------------------------------------------------------------
296 .\" HX n
298 .\"   Automatic heading level cut off.
300 .\"   N is the depth limit of automatically linked headings.  So a depth
301 .\"   of 2 would cause grohtml to generate a list of links for `.NH 1'
302 .\"   and `.NH 2' but not for `.NH 3'.
304 .de HX
305 .  if \\n[www-html] \
306 .    nop \X^index:\\$*^
308 .\" --------------------------------------------------------------------
309 .\" BCL foreground background active not-visited visited
311 .de BCL
312 .  HTML <body text=\\$1 bgcolor=\\$2 link=\\$3 alink=\\$4 vlink=\\$5>
314 .\" --------------------------------------------------------------------
315 .\" BGIMG imagefile
317 .de BGIMG
318 .  HTML <body background=\\$1>
320 .\" --------------------------------------------------------------------
321 .\" URL url [description] [after]
322 .\"     if description is absent then the url becomes the anchor text
324 .de URL
325 .  ds \\$0:adr \\$1\"
326 .  www:url_breaks \\$0:adr
327 .  ie \\n[www-html] \{\
328 .    ie '\\$3'' \
329 .      ds \\$0:after \&
330 .    el \
331 .      ds \\$0:after \&\\$3
332 .    ie '\\$2'' \
333 .       HTML-NS <a href="\\$1">\\$1</a>
334 .    el \
335 .       HTML-NS <a href="\\$1">\\$2</a>
336 .    nop \\*[\\$0:after]
337 .    rm \\$0:after
338 .  \}
339 .  el \{\
340 .    if !r ps4html .ad l
341 .    ie '\\$2'' \
342 .       nop \%\[la]\m[blue]\f[C]\\*[\\$0:adr]\f[]\m[]\[ra]\\$3
343 .    el \
344 .       nop \m[blue]\\$2\m[] \%\[la]\f[C]\\*[\\$0:adr]\f[]\[ra]\\$3
345 .    if !r ps4html .ad
346 .  \}
347 .  rm \\$0:adr
349 .\" --------------------------------------------------------------------
350 .\" FTP url description [after]
352 .\"   Same as URL.
354 .als FTP URL
355 .\" --------------------------------------------------------------------
356 .\" MTO address description [after]
358 .\"   ADDRESS is the email address (without the `mailto:' prefix).
360 .\"   DESCRIPTION is the optional name.  If an empty argument is given,
361 .\"   ADDRESS is used instead.
363 .\"   AFTER is optional stuff printed immediately after ADDRESS
364 .\"   (resp. DESCRIPTION).
366 .\"     Example:
368 .\"       Foobar has been written by
369 .\"       .MTO fred@foo.bar "Fredrick Bloggs" .
371 .de MTO
372 .  ie \\n[www-html] \{\
373 .    ie '\\$2'' \
374 .      URL mailto:\\$1 \\$1 "\\$3"
375 .    el \
376 .      URL mailto:\\$1 "\\$2" "\\$3"
377 .  \}
378 .  el \{\
379 .    ie '\\$2'' \
380 .      nop \%\m[blue]\f[C]\\$1\f[]\m[]\\$3
381 .    el \
382 .      nop \m[blue]\\$2\m[] \%\[la]\f[C]\\$1\f[]\[ra]\\$3
383 .  \}
385 .\" --------------------------------------------------------------------
386 .\" TAG name
388 .\"   Generate an html name NAME.
390 .de TAG
391 .  HTML <a name="\\$1"></a>
393 .\" --------------------------------------------------------------------
394 .\" IMG [-R|-L|-C] filename [width] [height]
396 .\"   Include an image of any type (will only work for -Thtml).
398 .\"   Alignment is centered by default (-C).
399 .\"   Default value for WIDTH is 1i.
400 .\"   If HEIGHT is not given, WIDTH is used as the height.
402 .de IMG
403 .  ie \\n[www-html] \{\
404 .    ie '\\$2'-R' \
405 .      DEVTAG ".right-image"
406 .    el \{\
407 .      ie '\\$2'-L' \
408 .        DEVTAG ".left-image"
409 .      el \
410 .        DEVTAG ".centered-image"
411 .    \}
412 .    nr www-width 100
413 .    if !'\\$3'' \
414 .      nr www-width \\$3
415 .    nr www-height \\n[www-width]
416 .    if !'\\$4'' \
417 .      nr www-height \\$4
418 .    HTML <img src="\\$1" alt="Image \\$1" \
419            width=\\n[www-width] height=\\n[www-height]>
420 .  \}
421 .  el \
422 .    nop \[la]\f[C]\\$1\f[]\[ra]
424 .\" --------------------------------------------------------------------
425 .\" PIMG  [-R|-L|-C] filename [width] [height]
427 .\"   Include a png image.  It will work for -Tps and -Thtml.
428 .\"   The default value for WIDTH and HEIGHT is zero; the default
429 .\"   alignment is centering (-C).
431 .\" Note: This macro can only be used with the `-U' option of groff,
432 .\"       activating unsafe mode, if not used with -Thtml; the PNG image
433 .\"       is then converted to the EPS format using netpbm utilities.
435 .de PIMG
436 .  ie \\n[www-html] \{\
437 .    ie '\\$1'-R' \
438 .      DEVTAG ".right-image"
439 .    el \{\
440 .      ie '\\$1'-L' \
441 .        DEVTAG ".left-image"
442 .      el \
443 .        DEVTAG ".centered-image"
444 .    \}
445 .    nr www-width 0
446 .    nr www-height 0
447 .    if !'\\$3'' \
448 .      nr www-width (\\$3 * 100 / 240)
449 .    if !'\\$4'' \
450 .      nr www-height (\\$4 * 100 / 240)
451 .    ie (\\n[www-width] == 0) \{\
452 .      ie (\\n[www-height] == 0) \
453 .        HTML <img src="\\$2" alt="Image \\$2">
454 .      el \
455 .        HTML <img src="\\$1" alt="Image \\$2" height=\\n[www-height]>
456 .    \}
457 .    el \{\
458 .      ie (\\n[www-height] == 0) \
459 .        HTML <img src="\\$2" alt="Image \\$2" width=\\n[www-width]>
460 .      el \
461 .        HTML <img src="\\$2" alt="Image \\$2" width=\\n[www-width] \
462                height=\\n[www-height]>
463 .    \}
464 .  \}
465 .  el \{\
466 .    if !r ps4html \{\
467 .      www-make-unique-name
468 .      sy pngtopnm \\$2 | pnmcrop -white | @PNMTOPS_NOSETPAGE@ -noturn > \\*[www-unique-name].eps
469 .      ie '\\$1'-C' \
470 .        PSPIC \\*[www-unique-name].eps \\$3 \\$4
471 .      el \
472 .        PSPIC \\$1 \\*[www-unique-name].eps \\$3 \\$4
473 .    \}
474 .  \}
477 .\" --------------------------------------------------------------------
478 .\" auxiliary definitions for MPIMG
480 .nr www-left-ll-trap 0
481 .nr www-left-po-trap 0
482 .nr www-right-ll-trap 0
484 .de www-finish-left-po
485 .  po -(\\n[www-left-indent]u + \\n[www-image-gap]u)
486 .  wh \\n[www-left-po-trap]u
487 .  nr www-left-indent 0
490 .\" called when the -R picture is finished
491 .de www-finish-right-ll
492 .  ll +(\\n[www-right-indent]u + \\n[www-image-gap]u)
493 .  \" now see whether we need to inline www-finish-left-ll
494 .  if (\\n[www-left-ll-trap]u > 0) \
495 .    if ((\\n[www-right-ll-trap]u + 1v) >= \\n[www-left-ll-trap]u) \{\
496 .      mk www-left-po-trap
497 .      nr www-left-po-trap +1v
498 .      wh \\n[www-left-po-trap]u www-finish-left-po
499 .      ll +\\n[www-left-indent]u
500 .      wh \\n[www-left-ll-trap]u
501 .      nr www-left-ll-trap 0
502 .    \}
503 .  \" and see whether we need to inline www-finish-left-po
504 .  if (\\n[www-left-po-trap]u > 0) \
505 .    if ((\\n[www-right-ll-trap]u + 1v) >= \\n[www-left-po-trap]u) \{\
506 .      po -\\n[www-left-indent]u
507 .      wh \\n[www-left-po-trap]u
508 .      nr www-left-indent 0
509 .    \}
510 .  wh \\n[www-right-ll-trap]u
511 .  nr www-right-ll-trap 0
514 .de www-finish-left-ll
515 .  if (\\n[www-right-ll-trap] > 0) \
516 .    if ((\\n[www-left-ll-trap] + 1v) >= \\n[www-right-ll-trap]) \{\
517 .      ll +\\n[www-right-indent]u
518 .      nr www-right-ll-trap 0
519 .    \}
520 .  mk www-left-po-trap
521 .  nr www-left-po-trap +1v
522 .  wh \\n[www-left-po-trap]u www-finish-left-po
523 .  ll +(\\n[www-left-indent]u + \\n[www-image-gap]u)
524 .  wh \\n[www-left-ll-trap]u
525 .  nr www-left-ll-trap 0
528 .\" www-handle-percent arg N1 N2 S1
529 .\"                    arg - input string (number or number%)
530 .\"                    output parameters:
531 .\"                    N1 - name of number register 1=absolute 0=percentage
532 .\"                    N2 - number register name for absolute value
533 .\"                    S1 - string register name for percentage value
535 .de www-handle-percent 
536 .  ds www-percent \\$1\"
537 .  substring www-percent -1 -1
539 .  ie '\\*[www-percent]'%' \{\
540 .    ds www-abs \\$1\"
541 .    substring www-abs 0 -2
542 .    nr \\$2 0
543 .    nr \\$3 \\*[www-abs]
544 .    ds \\$4 \\$1\"
545 .  \}
546 .  el \{\
547 .    nr \\$2 1
548 .    nr \\$3 \\$1
549 .    ds \\$4 none\"
550 .  \}
553 .\" --------------------------------------------------------------------
554 .\" MPIMG [-R|-L] [-G gap] filename [width [height]]
556 .\"   Include a png image and wrap text around it.  It will work for
557 .\"   -Tps and -Thtml.  The default value for WIDTH is 1i; default value
558 .\"   for HEIGHT is WIDTH; the default alignment is left (-L).
559 .\"   -G is used to insert a gap between the text and the image.
560 .\"   The height and width can also be given as a percentage.
561 .\"   The PostScript device converts the percentage width into an
562 .\"   absolute value by using \\n[.l], and the height by using \\n[.p].
563 .\"   
565 .\" Note: This macro can only be used with the `-U' option of groff,
566 .\"       activating unsafe mode, if not used with -Thtml; the PNG image
567 .\"       is then converted to the EPS format using netpbm utilities.
570 .nr www-htmlimage-gap 0
572 .de MPIMG
573 .  nr www-image-just 1
574 .  nr www-image-gap 0
575 .  while (\\n[.$] > 0) \{\
576 .    if '-L'\\$1' \{\
577 .      nr www-image-just 1
578 .      shift
579 .      continue
580 .    \}
581 .    if '-R'\\$1' \{\
582 .      nr www-image-just 0
583 .      shift
584 .      continue
585 .    \}
586 .    if '-G'\\$1' \{\
587 .      nr www-image-gap \\$2
588 .      nr www-htmlimage-gap (\\$2 * 100 / 240)
589 .      shift 2
590 .      continue
591 .    \}
592 .    break
593 .  \}
595 .  nr www-width 1i
596 .  nr www-height 1i
597 .  ds www-size-specs "width=\\n[www-width] height=\\n[www-height]\"
598 .  ie !'\\$2'' \{\
599 .    nr www-is-absolute 0
600 .    nr www-absolute 0
601 .    ds www-percentage none\"
602 .    www-handle-percent \\$2 www-is-absolute www-absolute www-percentage
603 .    ie !\\n[www-is-absolute] \{\
604 .      \" percentage of linelength requested
605 .      nr www-width (\\n[www-absolute] * \\n[.l] / 100)
606 .      if \\n[www-html] \
607 .        nr www-width (\\n[www-width] * 100 / 240)
608 .      ds www-size-specs "width=\\*[www-percentage]\"
609 .    \}
610 .    el \{\
611 .      nr www-width \\n[www-absolute]
612 .      if \\n[www-html] \
613 .        nr www-width (\\n[www-width] * 100 / 240)
614 .      ds www-size-specs "width=\\n[www-width]\"
615 .    \}
617 .    nr www-height \\n[www-width]
618 .    ie !'\\$3'' \{\
619 .      nr www-is-absolute 0
620 .      nr www-absolute 0
621 .      ds www-percentage none\"
622 .      www-handle-percent \\$3 www-is-absolute www-absolute www-percentage
623 .      ie !\\n[www-is-absolute] \{\
624 .        \" percentage of pagelength requested
625 .        nr www-height (\\n[www-absolute] * \\n[.p] / 100)
626 .        if \\n[www-html] \
627 .           nr www-height (\\n[www-height] * 100 / 240)
628 .        ds www-size-specs "\\*[www-size-specs] height=\\*[www-percentage]\"
629 .      \}
630 .      el \{\
631 .        nr www-height \\n[www-absolute]
632 .        if \\n[www-html] \
633 .           nr www-height (\\n[www-height] * 100 / 240)
634 .        ds www-size-specs "\\*[www-size-specs] height=\\*[www-height]\"
635 .      \}
636 .    \}
637 .  \}
638 .  el \{\
639 .    \" height not specified; use width value
640 .    ie !\\n[www-is-absolute] \{\
641 .       \" percentage value
642 .       ds www-size-specs "\\*[www-size-specs] height=\\*[www-percentage]\"
643 .       nr www-height \\n[www-width]
644 .    \}
645 .    el \{\
646 .       ds www-size-specs "\\*[www-size-specs] height=\\*[www-width]\"
647 .       nr www-height \\n[www-width]
648 .    \}
649 .  \}
651 .  ie \\n[www-html] \{\
652 .    ie !\\n[www-image-just] \
653 .      HTML <img src="\\$1" alt="Image \\$1" hspace=\\n[www-htmlimage-gap] \
654              align=right \\*[www-size-specs]>
655 .    el \
656 .      HTML <img src="\\$1" alt="Image \\$1" hspace=\\n[www-htmlimage-gap] \
657              align=left \\*[www-size-specs]>
658 .  \}
659 .  el \{\
660 .    tm www-width is \\n[www-width]
661 .    tm www-height is \\n[www-height]
662 .    if !r ps4html \{\
663 .      www-make-unique-name
664 .      sy pngtopnm \\$1 | pnmcrop -white | @PNMTOPS_NOSETPAGE@ -noturn > \\*[www-unique-name].eps
665 .      ie !\\n[www-image-just] \{\
666 .        \" we must now disable a possible left image trap
667 .        sp -1
668 .        if (\\n[www-left-ll-trap] > 0) \
669 .          wh \\n[www-left-ll-trap]u
670 .        if (\\n[www-left-po-trap] > 0) \
671 .          wh \\n[www-left-po-trap]u
672 .        PSPIC -R \\*[www-unique-name].eps \\n[www-width]u \\n[www-height]u
673 .        sp -\\n[ps-desht]u
674 .        nr www-right-indent \\n[ps-deswid]u
675 .        \" we want to have some space between text and image,
676 .        \" so the line length must be shorter
677 .        ll -(\\n[www-right-indent]u + \\n[www-image-gap]u)
678 .        mk www-right-ll-trap
679 .        nr www-right-ll-trap +(\\n[ps-desht]u - 1v)
680 .        wh \\n[www-right-ll-trap]u www-finish-right-ll
681 .        \" now restore possible left trap
682 .        if (\\n[www-left-ll-trap] > 0) \
683 .          wh \\n[www-left-ll-trap]u www-finish-left-ll
684 .        if (\\n[www-left-po-trap] > 0) \
685 .          wh \\n[www-left-po-trap]u
686 .      \}
687 .      el \{\
688 .        \" we must now disable a possible right image trap
689 .        if (\\n[www-right-ll-trap] > 0) \
690 .          wh \\n[www-right-ll-trap]u
691 .        PSPIC -L \\*[www-unique-name].eps \\n[www-width]u \\n[www-height]u
692 .        sp -\\n[ps-desht]u
693 .        nr www-left-indent \\n[ps-deswid]u
694 .        \" increase offset by gap
695 .        po +(\\n[www-left-indent]u + \\n[www-image-gap]u)
696 .        \" decrease line length by gap
697 .        ll -(\\n[www-left-indent]u + \\n[www-image-gap]u)
698 .        mk www-left-ll-trap
699 .        nr www-left-ll-trap +(\\n[ps-desht]u - 1v)
700 .        wh \\n[www-left-ll-trap]u www-finish-left-ll
701 .        \" now restore possible right trap
702 .        if (\\n[www-right-ll-trap] > 0) \
703 .          wh \\n[www-right-ll-trap]u www-finish-right-ll
704 .      \}
705 .    \}
706 .  \}
708 .\" --------------------------------------------------------------------
709 .\" HnS n
711 .\"   Begin heading.  Heading level is N.
713 .\" HnE
715 .\"   End heading.
717 .\" If your heading contains URL, FTP, MTO macros you might wish to
718 .\" disable automatic links to headings.  This can be done via `-P-l'
719 .\" from the command line or by using a cakk to `.HX 0'.
721 .nr www-heading-no -1
723 .de HnS
724 .  ie '\\$1'' \
725 .    nr www-heading-no 1
726 .  el \
727 .    nr www-heading-no \\$1
728 .  DEVTAG-NH \\n[www-heading-no]
731 .de HnE
732 .  if (\\n[www-heading-no] == -1) \
733 .    www-error "HnE found without a corresponding HnS"
734 .  DEVTAG-EO-H
736 .\" --------------------------------------------------------------------
737 .\" LK
739 .\"   Emit the automatically collected links derived from
740 .\"   section/numbered headings at this position.
742 .de LK
743 .  DEVTAG ".links"
745 .\" --------------------------------------------------------------------
746 .\" HR
748 .\"   Produce a horizontal line.
750 .de HR
751 .  HTML</p> "<hr>"
753 .\" --------------------------------------------------------------------
754 .\" NHR
756 .\"  Suppresses the generation of the top and bottom rules which grohtml
757 .\"  emits by default.
759 .de NHR
760 .  DEVTAG ".no-auto-rule"
763 .\" www-end-nowhere - end of input trap called to finish diversion.
765 .de www-end-nowhere
766 .  if !\\n[www-html] \
767 .    di
768 .  DEVTAG-EO-TL
770 .\" --------------------------------------------------------------------
771 .\" HTL
773 .\"   Generate an HTML title only.  This differs from the -ms .TL macro
774 .\"   which generates both an HTML title and an H1 heading.
776 .\"   This is useful when an author wishes to use a HTML title as search
777 .\"   engine fodder but a graphic title in the document.
779 .\"   The macro terminates when a space or break is seen (.sp, .br).
781 .de HTL
782 .  DEVTAG ".html-tl"
783 .  if !\\n[www-html] \
784 .    di www-nowhere
785 .  it 2 www-end-nowhere
788 .\" --------------------------------------------------------------------
789 .\" auxiliary definitions for lists
791 .ds www-ul-level1 \[bu]\ \ \"
792 .ds www-ul-level2 \[sq]\ \ \"
793 .ds www-ul-level3 \[ci]\ \ \"
794 .nr www-ul-level 0
796 .ds www-ol-level1 decimal\"
797 .ds www-ol-level2 lower-alpha\"
798 .ds www-ol-level3 lower-roman\"
799 .ds www-ol-tmp 00\ \ \"
800 .nr www-ol-ctr1 0 1
801 .nr www-ol-ctr2 0 1
802 .nr www-ol-ctr3 0 1
803 .af www-ol-ctr2 a
804 .af www-ol-ctr3 i
805 .nr www-ol-level 0
807 .nr www-dl-level 0
808 .nr www-dl-shift 5n
811 .\" allow nested lists
813 .nr www-depth 0
814 .nr www-li-indent \n[.i]
815 .ds www-level0 nop\"
816 .ds www-level1
817 .ds www-level2
818 .ds www-level3
819 .ds www-level4
820 .ds www-level5
821 .ds www-level6
822 .ds www-level7
823 .ds www-level8
824 .ds www-level9
826 .\" which macro to use for LI
827 .de www-push-li
828 .  nr www-depth +1
829 .  ds www-level\\n[www-depth] \\$1\"
830 .  als LI \\$1
833 .de www-pop-li
834 .  nr www-depth -1
835 .  als LI \\*[www-level\\n[www-depth]]
839 .\" Auxiliary macro for ULS.
841 .de www-push-ul-level
842 .  nr www-ul-level +1
843 .  if (\\n[www-ul-level] > 3) \
844 .    www-error "ULS: too many levels of indentation (\\n[www-ul-level])"
847 .\" Auxiliary macro for ULE.
849 .de www-pop-ul-level
850 .  if !\\n[www-ul-level] \
851 .    www-error "ULE: trying to terminate a list which does not exist"
852 .  nr www-ul-level -1
856 .\" Auxiliary macro for OLS.
858 .de www-push-ol-level
859 .  nr www-ol-level +1
860 .  if (\\n[www-ol-level] > 3) \
861 .    www-error "OLS: too many levels of indentation (\\n[www-ol-level])"
864 .\" Auxiliary macro for OLE.
866 .de www-pop-ol-level
867 .  if !\\n[www-ol-level] \
868 .    www-error "OLE: trying to terminate a list which does not exist"
869 .  nr www-ol-level -1
872 .\" --------------------------------------------------------------------
873 .\" ULS
875 .\"   Start an unordered list.
877 .de ULS
878 .  www-push-li www-li-ul
879 .  www-push-ul-level
880 .  ie \\n[www-html] \
881 .    HTML</p> "<ul>"
882 .  el \{\
883 .    nr www-li-indent +\w'\\*[www-ul-level\\n[www-ul-level]]'u
884 .  \}
886 .\" --------------------------------------------------------------------
887 .\" ULE
889 .\"   End an unordered list.
891 .de ULE
892 .  ie \\n[www-html] \
893 .    HTML "</ul>"
894 .  el \{\
895 .    nr www-li-indent -\w'\\*[www-ul-level\\n[www-ul-level]]'u
896 .    in \\n[www-li-indent]u
897 .  \}
898 .  www-pop-ul-level
899 .  www-pop-li
901 .\" --------------------------------------------------------------------
902 .\" OLS
904 .\"   Start an ordered list.
906 .de OLS
907 .  www-push-li www-li-ol
908 .  www-push-ol-level
909 .  ie \\n[www-html] \
910 .    HTML</p> "<ol style='list-style-type: \\*[www-ol-level\\n[www-ol-level]]'>"
911 .  el \
912 .    nr www-li-indent +\w'\\*[www-ol-tmp]'u
914 .\" --------------------------------------------------------------------
915 .\" OLE
917 .\"   End an ordered list.
919 .de OLE
920 .  ie \\n[www-html] \
921 .    HTML "</ol>"
922 .  el \{\
923 .    nr www-li-indent -\w'\\*[www-ol-tmp]'u
924 .    in \\n[www-li-indent]u
925 .    nr www-ol-ctr\\n[www-ol-level] 0 1
926 .  \}
927 .  www-pop-ol-level
928 .  www-pop-li
930 .\" --------------------------------------------------------------------
932 .\" DLS
933 .\"   Start a definition list.
935 .de DLS
936 .  www-push-li www-li-dl
937 .  nr www-dl-level +1
938 .  ie \\n[www-html] \
939 .    HTML</p> "<dl>"
940 .  el \{\
941 .    nr www-li-indent +\\n[www-dl-shift]u
942 .    in \\n[www-li-indent]u
943 .  \}
945 .\" --------------------------------------------------------------------
947 .\" DLE
948 .\"   End a definition list.
950 .de DLE
951 .  ie \\n[www-html] \
952 .    HTML "</dl>"
953 .  el \{\
954 .    nr www-li-indent -\\n[www-dl-shift]u
955 .    in \\n[www-li-indent]u
956 .  \}
957 .  nr www-dl-level -1
958 .  www-pop-li
960 .\" --------------------------------------------------------------------
961 .\" LI
963 .\"   Insert a list item.
965 .\" ********
966 .\" www-li-ul - bulleted list item
968 .de www-li-ul
969 .  ie \\n[www-html] \
970 .    HTML-NS "<li>"
971 .  el \{\
972 .    www:paraspace
973 .    in \\n[www-li-indent]u
974 .    ti -\w'\\*[www-ul-level\\n[www-ul-level]]'u
975 .    nop \\*[www-ul-level\\n[www-ul-level]]\c
976 .  \}
978 .\" ********
979 .\" www-li-ol - numbered list item
981 .de www-li-ol
982 .  ie \\n[www-html] \
983 .    HTML-NS "<li>"
984 .  el \{\
985 .    www:paraspace
986 .    in \\n[www-li-indent]u
987 .    ti -\w'\\n[www-ol-ctr\\n[www-ol-level]]\ \ 'u
988 .    nop \\n+[www-ol-ctr\\n[www-ol-level]]\ \ \c
989 .  \}
991 .\" ********
992 .\" www-li-dl - definition list item
994 .de www-li-dl
995 .  ie \\n[www-html] \{\
996 .    HTML "<dt>\\$1</dt>"
997 .    HTML-NS "<dd>"
998 .  \}
999 .  el \{\
1000 .    www:paraspace
1001 .    in \\n[www-li-indent]u
1002 .    ti -\\n[www-dl-shift]u
1003 .    nop \&\\$1
1004 .    br
1005 .  \}
1007 .\" --------------------------------------------------------------------
1008 .\" DC l text [color]
1010 .\"   L is the letter to be dropped and enlarged.
1012 .\"   TEXT is the following text whose height the first letter should not
1013 .\"   exceed.
1015 .\"   COLOR is the optional color of the dropped letter (default black).
1017 .de DC
1018 .  ds www-dropcolor black
1019 .  if !'\\$3'' \
1020 .    ds www-dropcolor \\$3
1021 .  ie '\*(.T'html' \{\
1022 .    www-make-unique-name
1023 .    nr www-drop-width (100u * \\n[.v]u * 3u / \\n[.l]u)
1024 .    MPIMG -L \\*[www-unique-name].png "\\n[www-drop-width]%"
1025 .  \}
1026 .  el \{\
1027 .    ie r ps4html \{\
1028 .      www-make-unique-name
1029 .      \" To avoid interferences with another DC macro call which is located
1030 .      \" very near to the current one, we draw the glyph on a separate page.
1031 .      \" Otherwise it could theoretically happen that the dropped capital
1032 .      \" glyphs overlap.
1033 .      bp
1034 .      ev www-DC
1035 .      vs 320p
1036 .      nop \O[5i\\*[www-unique-name].png]\O[1]
1037 .      nop \m[\\*[www-dropcolor]]\s[160]\O[3]\\$1\O[4]
1038 .      nop \O[2]\O[0]
1039 .      br
1040 .      ev
1041 .      bp
1042 .    \}
1043 .    el \{\
1044 .      ie n \
1045 .        nop \\$1\c
1046 .      el \{\
1047 .        nr dummy \w'\\$1'u
1048 .        nr dcht ((\\n[.v] + \\n[rst]) * \\n[.ps] / \\n[rst])
1049 .        char \[dcap] \m[\\*[www-dropcolor]]\s'\\n[dcht]u'\\$1
1050 .        nop \v'\\n[.v]u'\\[dcap]\v'-\\n[.v]u'\c
1051 '        ti \w'\\[dcap]'u
1052 .      \}
1053 .    \}
1054 .  \}
1055 .  nop \\$2
1057 .\" --------------------------------------------------------------------
1058 .\" Setup around HTML-IMAGE and friends
1060 .\" now set up TS, TE, EQ, EN default macros
1062 .do if !d TS .do ds TS HTML-IMAGE
1063 .do if !d TE .do ds TE HTML-IMAGE-END
1064 .do if !d EQ .do ds EQ HTML-IMAGE
1065 .do if !d EN .do ds EN HTML-IMAGE-END
1067 .\" supplementary macros used by other macro sets
1069 .\" here are some tags specially for -Tps or -Thtml when invoked by
1070 .\" pre-html to generate png images from postscript.
1072 .\" --------------------------------------------------------------------
1073 .\" HTML-DO-IMAGE - tells troff to issue an image marker which can be
1074 .\"                 read back by pre-html
1076 .de HTML-DO-IMAGE
1077 .  if r ps4html \
1078 .    nop \O[5\\$2\\$1.png]\O[1]\O[3]
1079 .  if \\n[www-html] \
1080 .    nop \O[5\\$2\\$1.png]\O[0]\O[3]
1082 .\" --------------------------------------------------------------------
1083 .\" HTML-IMAGE-END - terminates an image for html
1085 .de HTML-IMAGE-END
1086 .  if r ps4html \
1087 .    nop \O[4]\O[2]\O[0]
1088 .  if \\n[www-html] \
1089 .    nop \O[4]\O[2]\O[1]
1092 .nr www-png-no 0
1094 .\" --------------------------------------------------------------------
1095 .\" www-make-unique-name - generates another unique name in string
1096 .\"                        `www-unique-name'
1098 .de www-make-unique-name
1099 .  nr www-png-no +1
1100 .  ds www-unique-name \\*[www-image-template]\\n[www-png-no]
1102 .\" --------------------------------------------------------------------
1103 .\" HTML-IMAGE and friends tell grohtml that this region of text needs
1104 .\"            to be rendered as an image.
1106 .de HTML-IMAGE
1107 .  \" generates a centered image
1108 .  www-make-unique-name
1109 .  HTML-DO-IMAGE \\*[www-unique-name] c
1112 .de HTML-IMAGE-RIGHT
1113 .  www-make-unique-name
1114 .  HTML-DO-IMAGE \\*[www-unique-name] r
1117 .de HTML-IMAGE-LEFT
1118 .  www-make-unique-name
1119 .  HTML-DO-IMAGE \\*[www-unique-name] l
1122 .de HTML-IMAGE-INLINE
1123 .  www-make-unique-name
1124 .  HTML-DO-IMAGE \\*[www-unique-name] i
1127 .\" --------------------------------------------------------------------
1128 .\" JOBNAME
1130 .\"   Generate multiple output files containing the html.
1131 .\"   A file is split whenever a .SH or .NH 1 is encountered.
1132 .\"   The argument to JOBNAME is the file stem for future output files.
1134 .de JOBNAME
1135 .  DEVTAG .job-name \\$1
1137 .\" --------------------------------------------------------------------
1138 .\" HEAD
1140 .\"   Adds information to the <head> </head> section of the html
1141 .\"   document
1142 .\" --------------------------------------------------------------------
1143 .de HEAD
1144 .  DEVTAG .head "\\$*"
1146 .\" --------------------------------------------------------------------
1147 .\" Final Setup
1148 .\" --------------------------------------------------------------------
1150 .if \n[www-html] \{\
1151 .   nh
1152 .   nr HY 0
1156 .\" start of some code
1159 .de CDS
1160 .ft C
1164 .\" end of some code
1167 .de CDE
1169 .ft P
1172 .if r ps4html .nop \O[0]
1173 .cp \n(_C
1175 .\" now set
1177 .\" --------------------------------------------------------------------
1178 .\" Emacs settings
1179 .\" --------------------------------------------------------------------
1181 .\" Local Variables:
1182 .\" mode: nroff
1183 .\" End:
1184 .\" EOF