* doc/Makefile.sub: Not all shells expand wildcards in the `for'
[s-roff.git] / tmac / www.tmac
blob835240885a4671213411c9fa85a50dc1ccf493d9
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 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 .nr _C \n(.C
46 .cp 0
48 .nr www-html 0
49 .if '\*[.T]'html' .nr www-html 1
51 .\" set up www-image-template
53 .if !d www-image-template \
54 .  ds www-image-template
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 .\}
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
98 .www:@test_substring
99 .rm www:@test_substring
102 .\" --------------------------------------------------------------------
103 .\" Local Macros
104 .\" --------------------------------------------------------------------
106 .\" --------------------------------------------------------------------
107 .\" www:error (<test>...)
109 .\" Print error message
111 .de www-error
112 .  tm \\n[.F]:\\n[.c]: macro error: \\$*
114 .als www:error www-error
116 .\" --------------------------------------------------------------------
117 .\" www:lenstr (<register_name> <string_name>)
119 .\" Store length of string named <string_name> into register named
120 .\" <register_name>.
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
131 .\" --------------------------------------------------------------------
132 .\" www:splitstr (<name>)
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'.
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
166 .\" --------------------------------------------------------------------
167 .\" www:url_breaks (<string_name>)
169 .\" Add `\:' (possible break point) within URL strings after `/'.
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.
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
186 .\" --------------------------------------------------------------------
187 .\" www:url_breaks_splitted (<result> <char> [<char>...])
189 .\" Add `\:' within URL strings, but arguments are a splitted string.
191 .\" Arguments: >=2: <result> <char> [<char>...]
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
242 .\" --------------------------------------------------------------------
243 .\" User Interface
244 .\" --------------------------------------------------------------------
246 .\" --------------------------------------------------------------------
247 .\" HTML (<address> <description> [<punctuation>])
249 .\" the main auxiliary macro for the HTML interface
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 .  \}
259 .\" an auxiliary macro for HTML (without following space)
261 .de HTML-NS
262 .  if \\n[www-html] \
263 .    nop \X^html:\\$*^\c
265 .\" --------------------------------------------------------------------
266 .\" HX n
268 .\"   Automatic heading level cut off.
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'.
274 .de HX
275 .  if \\n[www-html] \
276 .    nop \X^index:\\$*^
278 .\" --------------------------------------------------------------------
279 .\" BCL foreground background active not-visited visited
281 .de BCL
282 .  HTML <body text=\\$1 bgcolor=\\$2 link=\\$3 alink=\\$4 vlink=\\$5>
284 .\" --------------------------------------------------------------------
285 .\" BGIMG imagefile
287 .de BGIMG
288 .  HTML <body background=\\$1>
290 .\" --------------------------------------------------------------------
291 .\" URL url [description] [after]
292 .\"     if description is absent then the url becomes the anchor text
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
313 .\" --------------------------------------------------------------------
314 .\" FTP url description [after]
316 .\"   Same as URL.
318 .als FTP URL
319 .\" --------------------------------------------------------------------
320 .\" MTO address description [after]
322 .\"   ADDRESS is the email address (without the `mailto:' prefix).
324 .\"   DESCRIPTION is the optional name.  If an empty argument is given,
325 .\"   ADDRESS is used instead.
327 .\"   AFTER is optional stuff printed immediately after ADDRESS
328 .\"   (resp. DESCRIPTION).
330 .\"     Example:
332 .\"       Foobar has been written by
333 .\"       .MTO fred@foo.bar "Fredrick Bloggs" .
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 .  \}
349 .\" --------------------------------------------------------------------
350 .\" TAG name
352 .\"   Generate an html name NAME.
354 .de TAG
355 .  HTML <a name="\\$1"></a>
357 .\" --------------------------------------------------------------------
358 .\" IMG [-R|-L|-C] filename [width] [height]
360 .\"   Include an image of any type (will only work for -Thtml).
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.
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]
387 .\" --------------------------------------------------------------------
388 .\" HTML-TAG
390 .\"   Emit a tag for grohtml.  This is an internal macro.
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 .  \}
399 .\" --------------------------------------------------------------------
400 .\" HTML-TAG-NS
402 .\"   Emit a tag for grohtml (without a space).  This is an internal macro.
404 .de HTML-TAG-NS
405 .  if \\n[www-html] \
406 .    nop \X^html-tag:\\$*^\c
408 .\" --------------------------------------------------------------------
409 .\" PIMG  [-R|-L|-C] filename [width] [height]
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).
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.
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 .  \}
460 .\" --------------------------------------------------------------------
461 .\" auxiliary definitions for MPIMG
463 .nr www-left-ll-trap 0
464 .nr www-left-po-trap 0
465 .nr www-right-ll-trap 0
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
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
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
510 .\" --------------------------------------------------------------------
511 .\" MPIMG [-R|-L] [-G gap] filename [width [height]]
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.
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.
523 .nr www-htmlimage-gap 0
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)
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 .  \}
611 .\" --------------------------------------------------------------------
612 .\" HnS n
614 .\"   Begin heading.  Heading level is N.
616 .\" HnE
618 .\"   End heading.
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'.
624 .nr www-heading-no -1
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]"
634 .de HnE
635 .  if (\\n[www-heading-no] == -1) \
636 .    www-error "HnE found without a corresponding HnS"
637 .  br
639 .\" --------------------------------------------------------------------
640 .\" LK
642 .\"   Emit the automatically collected links derived from
643 .\"   section/numbered headings at this position.
645 .de LK
646 .  HTML-TAG ".links"
648 .\" --------------------------------------------------------------------
649 .\" HR
651 .\"   Produce a horizontal line
653 .de HR
654 .  ie \\n[www-html] \{\
655 .    ti 0
656 .    HTML-NS <hr>
657 .  \}
658 .  el \
659 .    sp
661 .\" --------------------------------------------------------------------
662 .\" NHR
664 .\"  Suppresses the generation of the top and bottom rules which grohtml
665 .\"  emits by default.
667 .de NHR
668 .  HTML-TAG ".no-auto-rule"
671 .\" www-end-nowhere - end of input trap called to finish diversion.
673 .de www-end-nowhere
674 .  di
676 .\" --------------------------------------------------------------------
677 .\" HTL
679 .\"   Generate an HTML title only.  This differs from the -ms .TL macro
680 .\"   which generates both an HTML title and a H1 heading.
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.
685 .\"   The macro terminates when a space or break is seen (.sp, .br).
687 .de HTL
688 .  HTML-TAG ".html-tl"
689 .  if !\\n[www-html] \{\
690 .    di www-nowhere
691 .    it 2 www-end-nowhere
692 .  \}
695 .\" --------------------------------------------------------------------
696 .\" auxiliary definitions for ULS / ULE
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
705 .\" Auxiliary macro for ULS.
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])"
713 .\" Auxiliary macro for ULE.
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
720 .\" --------------------------------------------------------------------
721 .\" ULS
723 .\"   Start an unordered list.
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 .  \}
735 .\" --------------------------------------------------------------------
736 .\" ULE
738 .\"   End an unordered list.
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
749 .\" --------------------------------------------------------------------
750 .\" LI
752 .\"   Insert a list item.
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 .  \}
763 .\" --------------------------------------------------------------------
764 .\" DC l text [color]
766 .\"   L is the letter to be dropped and enlarged.
768 .\"   TEXT is the following text whose height the first letter should not
769 .\"   exceed.
771 .\"   COLOR is the optional color of the dropped letter (default black).
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 .      nr dummy \w'\\$1'u
800 .      nr dcht ((\\n[.v] + \\n[rst]) * \\n[.ps] / \\n[rst])
801 .      char \[dcap] \m[\\*[www-dropcolor]]\s'\\n[dcht]u'\\$1
802 .      nop \v'\\n[.v]u'\\[dcap]\v'-\\n[.v]u'\c
803 '      ti \w'\\[dcap]'u
804 .    \}
805 .  \}
806 .  nop \\$2
808 .\" --------------------------------------------------------------------
809 .\" Setup around HTML-IMAGE and friends
811 .\" now set up TS, TE, EQ, EN default macros
813 .do if !d TS .do ds TS HTML-IMAGE
814 .do if !d TE .do ds TE HTML-IMAGE-END
815 .do if !d EQ .do ds EQ HTML-IMAGE
816 .do if !d EN .do ds EN HTML-IMAGE-END
818 .\" supplementary macros used by other macro sets
820 .\" here are some tags specially for -Tps or -Thtml when invoked by
821 .\" pre-html to generate png images from postscript.
823 .\" --------------------------------------------------------------------
824 .\" HTML-DO-IMAGE - tells troff to issue an image marker which can be
825 .\"                 read back by pre-html
827 .de HTML-DO-IMAGE
828 .  if r ps4html \
829 .    nop \O[5\\$2\\$1.png]\O[1]\O[3]
830 .  if \\n[www-html] \
831 .    nop \O[5\\$2\\$1.png]\O[0]\O[3]
833 .\" --------------------------------------------------------------------
834 .\" HTML-IMAGE-END - terminates an image for html
836 .de HTML-IMAGE-END
837 .  if r ps4html \
838 .    nop \O[4]\O[2]\O[0]
839 .  if \\n[www-html] \
840 .    nop \O[4]\O[2]\O[1]
843 .nr www-png-no 0
845 .\" --------------------------------------------------------------------
846 .\" www-make-unique-name - generates another unique name in string
847 .\"                        `www-unique-name'
849 .de www-make-unique-name
850 .  nr www-png-no +1
851 .  ds www-unique-name \\*[www-image-template]\\n[www-png-no]
853 .\" --------------------------------------------------------------------
854 .\" HTML-IMAGE and friends tell grohtml that this region of text needs
855 .\"            to be rendered as an image.
857 .de HTML-IMAGE
858 .  \" generates a centered image
859 .  www-make-unique-name
860 .  HTML-DO-IMAGE \\*[www-unique-name] c
863 .de HTML-IMAGE-RIGHT
864 .  www-make-unique-name
865 .  HTML-DO-IMAGE \\*[www-unique-name] r
868 .de HTML-IMAGE-LEFT
869 .  www-make-unique-name
870 .  HTML-DO-IMAGE \\*[www-unique-name] l
873 .de HTML-IMAGE-INLINE
874 .  www-make-unique-name
875 .  HTML-DO-IMAGE \\*[www-unique-name] i
878 .\" --------------------------------------------------------------------
879 .\" JOBNAME
881 .\"   Generate multiple output files containing the html.
882 .\"   A file is split whenever a .SH or .NH 1 is encountered.
883 .\"   The argument to JOBNAME is the file stem for future output files.
885 .de JOBNAME
886 .  HTML-TAG .job-name \\$1
888 .\" --------------------------------------------------------------------
889 .\" Final Setup
890 .\" --------------------------------------------------------------------
892 .if \n[www-html] \{\
893 .   nh
894 .   nr HY 0
898 .\" start of some code
901 .de CDS
902 .ft C
906 .\" end of some code
909 .de CDE
911 .ft P
914 .if r ps4html .nop \O[0]
915 .cp \n(_C
917 .\" now set
919 .\" --------------------------------------------------------------------
920 .\" Emacs settings
921 .\" --------------------------------------------------------------------
923 .\" Local Variables:
924 .\" mode: nroff
925 .\" End:
926 .\" EOF