* src/roff/troff/TODO: Mention local variables.
[s-roff.git] / tmac / www.tmac
blob5c6904f5d02a6c65d3be1854ac842444569b8fcb
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, 2006, 2008
14   Free Software Foundation, Inc.
15 written by Gaius Mulley <gaius@glam.ac.uk>, with additions by
16 Werner Lemberg <wl@gnu.org> and Bernd Warken <bwarken@mayn.de>.
18 groff is free software; you can redistribute it and/or modify it under
19 the terms of the GNU General Public License as published by the Free
20 Software Foundation; either version 2, or (at your option) any later
21 version.
23 groff is distributed in the hope that it will be useful, but WITHOUT
24 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
26 for more details.
28 You should have received a copy of the GNU General Public License
29 along with groff; see the file COPYING.  If not, write to the Free
30 Software Foundation, 51 Franklin St - Fifth Floor, Boston, MA
31 02110-1301, USA.
34 ------------------------------------------------------------------------
35     Description
36 ------------------------------------------------------------------------
38 A simple set of macros to provide HTML (or XHTML) documents with basic
39 www functionality.  It should work with any macro set.  In the following,
40 HTML always denotes XHTML also.
44 .\" --------------------------------------------------------------------
45 .\" Setup
46 .\" --------------------------------------------------------------------
48 .do if d www:lenstr .nx
50 .do mso devtag.tmac
52 .nr _C \n(.C
53 .cp 0
56 .ie r xhtml \
57 .  ds www-> />\"
58 .el \
59 .  ds www-> >\"
61 .nr www-html 0
62 .if '\*[.T]'html' \
63 .  nr www-html 1
65 .\" set up www-image-template
67 .if !d www-image-template \
68 .  ds www-image-template
70 .if r ps4html \{\
71 .  \" remove the title command when we are generating images for HTML
72 .  \" (stops a title accidentally appearing inside an image)
73 .  di www-notitle
74 .  tl ''''
75 .  di
76 .  rm tl
77 .  de tl
78 .  .
79 .\}
82 .\" --------------------------------------------------------------------
83 .\" Test for `.substring'; result in register `www.substring_ok'.
84 .\" The automated break points in .URL addresses are only added if
85 .\" this register is non-zero.
86 .\"
87 .nr www:substring_ok 0
88 .de www:@test_substring
89 .  if !d substring \
90 .    return
91 .  ds \\$0:s abcdefg\"
92 .  substring \\$0:s 1 1
93 .  if !'\\*[\\$0:s]'b' \{\
94 .    rm \\$0:s
95 .    return
96 .  \}
97 .  ds \\$0:s abcdefg\"
98 .  substring \\$0:s 0 0
99 .  if !'\\*[\\$0:s]'a' \{\
100 .    rm \\$0:s
101 .    return
102 .  \}
103 .  ds \\$0:s abcdefg\"
104 .  substring \\$0:s 1 -1
105 .  if !'\\*[\\$0:s]'bcdefg' \{\
106 .    rm \\$0:s
107 .    return
108 .  \}
109 .  nr www:substring_ok 1
110 .  rm \\$0:s
112 .www:@test_substring
113 .rm www:@test_substring
116 .\" --------------------------------------------------------------------
117 .\" Local Macros
118 .\" --------------------------------------------------------------------
120 .\" --------------------------------------------------------------------
121 .\" www:paraspace
123 .\" Space before paragraph. Use \n[PD] if it exists.
125 .nr www:pd 0.5v
127 .de www:paraspace
128 .  ie r PD \
129 .    sp \\n[PD]u
130 .  el \
131 .    sp \\n[www:pd]u
134 .\" --------------------------------------------------------------------
135 .\" www:error (<test>...)
137 .\" Print error message.
139 .de www-error
140 .  tm \\n[.F]:\\n[.c]: macro error: \\$*
143 .als www:error www-error
145 .\" --------------------------------------------------------------------
146 .\" www:lenstr (<register_name> <string_name>)
148 .\" Store length of string named <string_name> into register named
149 .\" <register_name>.
151 .de www:lenstr
152 .  if !(\\n[.$] == 2) \{\
153 .    tm .\\$0 expects 2 arguments.
154 .    ab
155 .  \}
156 .  length \\$0:n x\\*[\\$2]
157 .  nr \\$1 (\\n[\\$0:n] - 1)
158 .  rr \\$0:n
161 .\" --------------------------------------------------------------------
162 .\" www:splitstr (<name>)
164 .\" Add a space character between any two adjacent characters in string
165 .\" <name> and restore result into the string variable <name>; space
166 .\" characters are first replaced by the word `space'.
168 .de www:splitstr
169 .  if !(\\n[.$] == 1) \
170 .    www:error .\\$0 expects 1 argument.
171 .  if '\\*[\\$1]'' \
172 .    return
173 .  ds \\$0:r "\\*[\\$1]\"
174 .  ds \\$0:s
175 .  while 1 \{\
176 .    ds \\$0:c "\\*[\\$0:r]\"
177 .    substring \\$0:c 0 0
178 .    ie '\\*[\\$0:c]' ' \
179 .      as \\$0:s " space\"
180 .    el \
181 .      as \\$0:s " \\*[\\$0:c]\"
182 .    www:lenstr \\$0:n \\$0:r
183 .    if (\\n[\\$0:n] <= 1) \
184 .      break
185 .    substring \\$0:r 1 -1
186 .  \}
187 .  if !'\\*[\\$0:s]'' \
188 .    substring \\$0:s 1 -1 
189 .  ds \\$1 \\*[\\$0:s]\"
190 .  rm \\$0:c
191 .  rr \\$0:n
192 .  rm \\$0:r
193 .  rm \\$0:s
196 .\" --------------------------------------------------------------------
197 .\" www:url_breaks (<string_name>)
199 .\" Add `\:' (possible break point) within URL strings after `/'.
201 .\" Smart about multiple `/', existing `\:', and space characters;
202 .\" does not set a break point if less than 5 characters would go to
203 .\" the next line.
205 .de www:url_breaks
206 .  if !(\\n[.$] == 1) \
207 .    www:error .\\$0 expects 1 argument.
208 .  if !\n[www:substring_ok] \
209 .    return
210 .  ds \\$0:s "\\*[\\$1]\"
211 .  www:splitstr \\$0:s
212 .  www:url_breaks_split \\$0:s \\*[\\$0:s]
213 .  ds \\$1 "\\*[\\$0:s]\"
214 .  rm \\$0:s
217 .\" --------------------------------------------------------------------
218 .\" www:url_breaks_split (<result> <char> [<char>...])
220 .\" Add `\:' within URL strings, but arguments are a split string.
222 .\" Arguments: >=2: <result> <char> [<char>...]
224 .de www:url_breaks_split
225 .  nr \\$0:min 5             \" minimal number of characters for next line
226 .  if (\\n[.$] < 2) \
227 .    www:error .\\$0 expects at least 2 arguments.
228 .  ds \\$0:res \\$1\"
229 .  shift
230 .  ds \\$0:s
231 .  nr \\$0:done 0
232 .  while !\\n[\\$0:done] \{\
233 .    if (\\n[.$] <= 0) \
234 .      break
235 .    if '\\$1'space' \{\
236 .      as \\$0:s " \"
237 .      shift
238 .      continue
239 .    \}
240 .    if (\\n[.$] < \\n[\\$0:min]) \{\
241 .      as \\$0:s "\\$1\"
242 .      shift
243 .      continue
244 .    \}
245 .    if !'\\$1'/' \{\
246 .      as \\$0:s "\\$1\"
247 .      shift
248 .      continue
249 .    \}
250 .    \" we are at a `/' character
251 .    while '\\$1'/' \{\
252 .      as \\$0:s /\"
253 .      if (\\n[.$] == 0) \{\
254 .        nr \\$0:done 1
255 .        break
256 .      \}
257 .      shift
258 .    \}
259 .    if \\n[\\$0:done] \
260 .      break
261 .    if (\\n[.$] < \\n[\\$0:min]) \
262 .      continue
263 .    if '\\$1'\:' \
264 .      shift
265 .    as \\$0:s \:\"
266 .  \}
267 .  ds \\*[\\$0:res] \\*[\\$0:s]\"
268 .  rm \\$0:res
269 .  rm \\$0:s
273 .\" --------------------------------------------------------------------
274 .\" User Interface
275 .\" --------------------------------------------------------------------
277 .\" --------------------------------------------------------------------
278 .\" HTML
280 .\" The main auxiliary macro for the HTML interface.
282 .de HTML
283 .  if \\n[www-html] \{\
284 .    \" was implemented via .nop \&\X^html:\\$*^ but
285 .    \" is now implemented using HTML-NS to utilize code factoring.
286 .    \"
287 .    \" the `\&' makes the vertical mode leave, so to say
288 .    \"
289 .    nop \&\c
290 .    HTML-NS \\$*
291 .    nop \&
292 .  \}
296 .\" An auxiliary macro for HTML (without following space).
298 .de HTML-NS
299 .  nop \X^html:\\$*^\c
303 .\" Emit an HTML tag after shutting down a (possibly open) paragraph.
305 .de HTML</p>
306 .  ie \\n[www-html] \{\
307 .    \" the `\&' makes the vertical mode leave, so to say
308 .    nop \&\X^html</p>:\\$*^
309 .  \}
310 .  el \
311 .    www:paraspace
315 .\" Emit an HTML tag.  If text has been written in the paragraph
316 .\"                    then do not shut the paragraph down.
317 .\"                    If text was not written, remove the empty
318 .\"                    paragraph tag and emit the desired HTML tag.
320 .de HTML<?p>
321 .  if \\n[www-html] \
322 .    nop \&\X^html<?p>:\\$*^
326 .\" Emit a MATH tag.  If text has been written in the paragraph
327 .\"                   then do not shut the paragraph down.
328 .\"                   If text was not written, remove the empty
329 .\"                   paragraph tag and emit the desired math tag.
331 .de MATH<?p>
332 .  if \\n[www-html] \
333 .    nop \&\X^math<?p>:\\$*^
336 .\" --------------------------------------------------------------------
337 .\" HX n
339 .\"   Automatic heading level cut off.
341 .\"   N is the depth limit of automatically linked headings.  So a depth
342 .\"   of 2 would cause grohtml to generate a list of links for `.NH 1'
343 .\"   and `.NH 2' but not for `.NH 3'.
345 .de HX
346 .  if \\n[www-html] \
347 .    nop \X^index:\\$*^
350 .\" --------------------------------------------------------------------
351 .\" BCL foreground background active not-visited visited
353 .de BCL
354 .  HTML <body "text=""\\$1""" \
355               "bgcolor=""\\$2""" \
356               "link=""\\$3""" \
357               "alink=""\\$4""" \
358               "vlink=""\\$5"">"
361 .\" --------------------------------------------------------------------
362 .\" BGIMG imagefile
364 .de BGIMG
365 .  HTML <body "background=""\\$1"">"
368 .\" www:url_check_tag str
369 .\"    If url named by \*[str] is internal (starts with #), 
370 .\"    redefine \*[str] to be the value of the string TAG_url.
372 .de www:url_check_tag
373 .  ds \\$0:tmp \\*[\\$1]\"
374 .  substring \\$0:tmp 0 0
375 .  if '\\*[\\$0:tmp]'#' \{\
376 .    ds \\$0:tmp \\*[\\$1]\"
377 .    substring \\$0:tmp 1
378 .    ds \\$0:tmp TAG_\\*[\\$0:tmp]\"
380 .    ie d \\*[\\$0:tmp] \
381 .      ds \\$1 \\*[\\*[\\$0:tmp]]\"
382 .    el \
383 .      ds \\$1 see below\"
384 .  \} 
385 .  rm \\$0:tmp
388 .\" --------------------------------------------------------------------
389 .\" URL url [description] [after]
391 .\"   If description is absent then the url becomes the anchor text.
393 .de URL
394 .  if !'\\$1'' \{\
395 .    ds \\$0:adr \\$1\"
396 .    www:url_check_tag \\$0:adr
397 .    if !\\n[www-html] \
398 .      www:url_breaks \\$0:adr
399 .  \}
400 .  ie \\n[www-html] \{\
401 .    ie '\\$3'' \
402 .      ds \\$0:after \&\"
403 .    el \
404 .      ds \\$0:after \&\\$3\"
406 .    ie '\\$2'' \
407 .       HTML-NS <a "href=""\\$1"">\\*[\\$0:adr]</a>"
408 .    el \
409 .       HTML-NS <a "href=""\\$1"">\\$2</a>"
411 .    nop \\*[\\$0:after]
412 .    rm \\$0:after
413 .  \}
414 .  el \{\
415 .    if !r ps4html \
416 .      ad l
418 .    ie '\\$2'' \{\
419 .      ie '\\$1'' \{\
420 .        if !'\\$3'' \
421 .          nop \\$3
422 .      \}
423 .      el \{\
424 .        ie \\n[.color] \
425 .          nop \%\\*[www:open]\m[\\*[www:color]]\f[\\*[www:fontstyle]]\\*[\\$0:adr]\f[]\m[]\\*[www:close]\\$3
426 .        el \
427 .          nop \%\\*[www:open]\f[\\*[www:fontstyle]]\\*[\\$0:adr]\f[]\\*[www:close]\\$3
428 .      \}
429 .    \}
430 .    el \{\
431 .      ie '\\$1'' \{\
432 .        ie \\n[.color] \
433 .          nop \m[\\*[www:color]]\\$2\m[]\\$3
434 .        el \
435 .          nop \f[\\*[www:fontstyle]]\\$2\f[]\\$3
436 .      \}
437 .      el \{\
438 .        ie \\n[.color] \{\
439 .          nop \m[\\*[www:color]]\\$2\m[]
440 .          nop \%\\*[www:open]\f[\\*[www:fontstyle]]\\*[\\$0:adr]\f[]\\*[www:close]\\$3
441 .        \}
442 .        el \{\
443 .          nop \f[\\*[www:fontstyle]]\\$2\f[]
444 .          nop \%\\*[www:open]\f[\\*[www:fontstyle]]\\*[\\$0:adr]\f[]\\*[www:close]\\$3
445 .        \}
446 .      \}
447 .    \}
449 .    if !r ps4html \
450 .      ad
451 .  \}
452 .  rm \\$0:adr
455 .\" --------------------------------------------------------------------
456 .\" FTP url description [after]
458 .\"   Same as URL.
460 .als FTP URL
462 .\" --------------------------------------------------------------------
463 .\" MTO address description [after]
465 .\"   ADDRESS is the email address (without the `mailto:' prefix).
467 .\"   DESCRIPTION is the optional name.  If an empty argument is given,
468 .\"   ADDRESS is used instead.
470 .\"   AFTER is optional stuff printed immediately after ADDRESS
471 .\"   (resp. DESCRIPTION).
473 .\"     Example:
475 .\"       Foobar has been written by
476 .\"       .MTO fred@foo.bar "Fredrick Bloggs" .
478 .de MTO
479 .  ie \\n[www-html] \{\
480 .    ie '\\$2'' \
481 .      URL mailto:\\$1 \\$1 "\\$3"
482 .    el \
483 .      URL mailto:\\$1 "\\$2" "\\$3"
484 .  \}
485 .  el \{\
486 .    ie '\\$2'' \{\
487 .      ie '\\$1'' \{\
488 .        ie !'\\$3'' \
489 .          nop \\$3
490 .      \}
491 .      el \{\
492 .        ie \\n[.color] \
493 .          nop \%\m[\\*[www:color]]\f[\\*[www:fontstyle]]\\$1\f[]\m[]\\$3
494 .        el \
495 .          nop \%\f[\\*[www:fontstyle]]\\$1\f[]\\$3
496 .      \}
497 .    \}
498 .    el \{\
499 .      ie '\\$1'' \{\
500 .        ie \\n[.color] \
501 .          nop \m[\\*[www:color]]\\$2\m[]\\$3
502 .        el \
503 .          nop \f[\\*[www:fontstyle]]\\$2\f[]\\$3
504 .      \}
505 .      el \{\
506 .        ie \\n[.color] \{\
507 .          nop \m[\\*[www:color]]\\$2\m[]
508 .          nop \%\\*[www:open]\f[\\*[www:fontstyle]]\\$1\f[]\\*[www:close]\\$3
509 .        \}
510 .        el \{\
511 .          nop \f[\\*[www:fontstyle]]\\$2\f[]
512 .          nop \%\\*[www:open]\f[\\*[www:fontstyle]]\\$1\f[]\\*[www:close]\\$3
513 .        \}
514 .      \}
515 .    \}
516 .  \}
519 .\" --------------------------------------------------------------------
520 .\" TAG name [text]
522 .\"   Generate an HTML name NAME.
523 .\"   Define string TAG_NAME to TEXT, if present, otherwise to \n[PN].
525 .de TAG
526 .  HTML <a "name=""\\$1""></a>"
527 .  ie '\\$2'' \
528 .    ds TAG_\\$1 \\n[PN]\"
529 .  el \
530 .    ds TAG_\\$1 \\$2\"
533 .\" --------------------------------------------------------------------
534 .\" IMG [-R|-L|-C] filename [width] [height]
536 .\"   Include an image of any type (only works for -Thtml).
538 .\"   Alignment is centered by default (-C).
539 .\"   Default value for WIDTH is 1i.
540 .\"   If HEIGHT is not given, WIDTH is used as the height.
542 .de IMG
543 .  ie \\n[www-html] \{\
544 .    ie '\\$2'-R' \
545 .      DEVTAG .right-image
546 .    el \{\
547 .      ie '\\$2'-L' \
548 .        DEVTAG .left-image
549 .      el \
550 .        DEVTAG .centered-image
551 .    \}
552 .    nr www-width 100
553 .    if !'\\$3'' \
554 .      nr www-width \\$3
555 .    nr www-height \\n[www-width]
556 .    if !'\\$4'' \
557 .      nr www-height \\$4
558 .    HTML <img "src=""\\$1""" \
559                "alt=""Image \\$1""" \
560                "width=""\\n[www-width]""" \
561                "height=""\\n[www-height]""\\*[www->]"
562 .  \}
563 .  el \
564 .    nop \\*[www:open]\f[\\*[www:fontstyle]]\\$1\f[]\\*[www:close]
567 .\" --------------------------------------------------------------------
568 .\" PIMG  [-R|-L|-C] filename [width] [height]
570 .\"   Include a PNG image.  It works for -Tps and -Thtml.
571 .\"   The default value for WIDTH and HEIGHT is zero; the default
572 .\"   alignment is centering (-C).
574 .\" Note: This macro can only be used with the `-U' option of groff,
575 .\"       activating unsafe mode, if not used with -Thtml; the PNG image
576 .\"       is then converted to the EPS format using netpbm utilities.
578 .de PIMG
579 .  ds www-pic-align -C\"
580 .  ie '\\$1'-R' \{\
581 .    ds www-pic-align -R\"
582 .    shift
583 .  \}
584 .  el \{\
585 .    if '\\$1'-L' \{\
586 .      ds www-pic-align -L\"
587 .      shift
588 .    \}
589 .  \}
590 .  if '\\$1'-C' \
591 .    shift
593 .  ie \\n[www-html] \{\
594 .    ds www-htmlalign align="center"\"
595 .    if '\\*[www-pic-align]'-R' \
596 .      ds www-htmlalign align="right"\"
597 .    if '\\*[www-pic-align]'-L' \
598 .      ds www-htmlalign align="left"\"
600 .    nr www-width 0
601 .    nr www-height 0
602 .    if !'\\$2'' \
603 .      nr www-width (\\$3 * 100 / 240)
604 .    if !'\\$3'' \
605 .      nr www-height (\\$4 * 100 / 240)
606 .    ie (\\n[www-width] == 0) \{\
607 .      ie (\\n[www-height] == 0) \
608 .        HTML</p> <p \\*[www-htmlalign]><img "src=""\\$1""" \
609                                              "alt=""Image \\$1""\\*[www->]</p>"
610 .      el \
611 .        HTML</p> <p \\*[www-htmlalign]><img "src=""\\$1""" \
612                                              "alt=""Image \\$1""" \
613                                              "height=""\\n[www-height]""\\*[www->]</p>"
614 .    \}
615 .    el \{\
616 .      ie (\\n[www-height] == 0) \
617 .        HTML</p> <p \\*[www-htmlalign]><img "src=""\\$1""" \
618                                              "alt=""Image \\$1""" \
619                                              "width=""\\n[www-width]""\\*[www->]</p>"
620 .      el \
621 .        HTML</p> <p \\*[www-htmlalign]><img "src=""\\$1""" \
622                                              "alt=""Image \\$1""" \
623                                              "width=""\\n[www-width]""" \
624                                              "height=""\\n[www-height]""\\*[www->]</p>"
625 .    \}
626 .  \}
627 .  el \{\
628 .    if !r ps4html \{\
629 .      www-make-unique-name
630 .      sy pngtopnm \\$1 \
631           | pnmcrop -white \
632           | @PNMTOPS_NOSETPAGE@ -noturn \
633           > \\*[www-unique-name].eps
634 .      shift
635 .      PSPIC \\*[www-pic-align] \\*[www-unique-name].eps \\$*
636 .    \}
637 .  \}
640 .\" --------------------------------------------------------------------
641 .\" auxiliary definitions for MPIMG
643 .nr www-left-ll-trap 0
644 .nr www-left-po-trap 0
645 .nr www-right-ll-trap 0
647 .de www-finish-left-po
648 .  po -(\\n[www-left-indent]u + \\n[www-image-gap]u)
649 .  wh \\n[www-left-po-trap]u
650 .  nr www-left-indent 0
653 .\" called when the -R picture is finished
654 .de www-finish-right-ll
655 .  ll +(\\n[www-right-indent]u + \\n[www-image-gap]u)
657 .  \" now check whether we need to inline www-finish-left-ll
658 .  if (\\n[www-left-ll-trap]u > 0) \
659 .    if ((\\n[www-right-ll-trap]u + 1v) >= \\n[www-left-ll-trap]u) \{\
660 .      mk www-left-po-trap
661 .      nr www-left-po-trap +1v
662 .      wh \\n[www-left-po-trap]u www-finish-left-po
663 .      ll +\\n[www-left-indent]u
664 .      wh \\n[www-left-ll-trap]u
665 .      nr www-left-ll-trap 0
666 .    \}
668 .  \" and check whether we need to inline www-finish-left-po
669 .  if (\\n[www-left-po-trap]u > 0) \
670 .    if ((\\n[www-right-ll-trap]u + 1v) >= \\n[www-left-po-trap]u) \{\
671 .      po -\\n[www-left-indent]u
672 .      wh \\n[www-left-po-trap]u
673 .      nr www-left-indent 0
674 .    \}
676 .  wh \\n[www-right-ll-trap]u
677 .  nr www-right-ll-trap 0
680 .de www-finish-left-ll
681 .  if (\\n[www-right-ll-trap] > 0) \
682 .    if ((\\n[www-left-ll-trap] + 1v) >= \\n[www-right-ll-trap]) \{\
683 .      ll +\\n[www-right-indent]u
684 .      nr www-right-ll-trap 0
685 .    \}
687 .  mk www-left-po-trap
688 .  nr www-left-po-trap +1v
689 .  wh \\n[www-left-po-trap]u www-finish-left-po
690 .  ll +(\\n[www-left-indent]u + \\n[www-image-gap]u)
691 .  wh \\n[www-left-ll-trap]u
692 .  nr www-left-ll-trap 0
695 .\" www-handle-percent arg N1 N2 S1
696 .\"                    arg - input string (number or number%)
697 .\"                    output parameters:
698 .\"                    N1 - name of number register 1=absolute 0=percentage
699 .\"                    N2 - number register name for absolute value
700 .\"                    S1 - string register name for percentage value
702 .de www-handle-percent 
703 .  ds www-percent \\$1\"
704 .  substring www-percent -1 -1
706 .  ie '\\*[www-percent]'%' \{\
707 .    ds www-abs \\$1\"
708 .    substring www-abs 0 -2
709 .    nr \\$2 0
710 .    nr \\$3 \\*[www-abs]
711 .    ds \\$4 \\$1\"
712 .  \}
713 .  el \{\
714 .    nr \\$2 1
715 .    nr \\$3 \\$1
716 .    ds \\$4 none\"
717 .  \}
720 .\" --------------------------------------------------------------------
721 .\" MPIMG [-R|-L] [-G gap] filename [width [height]]
723 .\"   Include a PNG image and wrap text around it.  It works for
724 .\"   -Tps and -Thtml.  The default value for WIDTH is 1i; default value
725 .\"   for HEIGHT is WIDTH; the default alignment is left (-L).
726 .\"   -G is used to insert a gap between the text and the image.
727 .\"   The height and width can also be given as a percentage.
728 .\"   The PostScript device converts the percentage width into an
729 .\"   absolute value by using \\n[.l], and the height by using \\n[.p].
730 .\"   
732 .\" Note: This macro can only be used with the `-U' option of groff,
733 .\"       activating unsafe mode, if not used with -Thtml; the PNG image
734 .\"       is then converted to the EPS format using netpbm utilities.
736 .nr www-htmlimage-gap 0
738 .de MPIMG
739 .  nr www-image-just 1
740 .  nr www-image-gap 0
741 .  while (\\n[.$] > 0) \{\
742 .    if '-L'\\$1' \{\
743 .      nr www-image-just 1
744 .      shift
745 .      continue
746 .    \}
747 .    if '-R'\\$1' \{\
748 .      nr www-image-just 0
749 .      shift
750 .      continue
751 .    \}
752 .    if '-G'\\$1' \{\
753 .      nr www-image-gap \\$2
754 .      nr www-htmlimage-gap (\\$2 * 100 / 240)
755 .      shift 2
756 .      continue
757 .    \}
758 .    break
759 .  \}
761 .  nr www-width 1i
762 .  nr www-height 1i
763 .  ds www-size-specs width="\\n[www-width]" height="\\n[www-height]"\"
764 .  ie !'\\$2'' \{\
765 .    nr www-is-absolute 0
766 .    nr www-absolute 0
767 .    ds www-percentage none\"
768 .    www-handle-percent \\$2 www-is-absolute www-absolute www-percentage
769 .    ie !\\n[www-is-absolute] \{\
770 .      \" percentage of linelength requested
771 .      nr www-width (\\n[www-absolute] * \\n[.l] / 100)
772 .      if \\n[www-html] \
773 .        nr www-width (\\n[www-width] * 100 / 240)
774 .      ds www-size-specs width="\\*[www-percentage]"\"
775 .    \}
776 .    el \{\
777 .      nr www-width \\n[www-absolute]
778 .      if \\n[www-html] \
779 .        nr www-width (\\n[www-width] * 100 / 240)
780 .      ds www-size-specs width="\\n[www-width]"\"
781 .    \}
783 .    nr www-height \\n[www-width]
784 .    ie !'\\$3'' \{\
785 .      nr www-is-absolute 0
786 .      nr www-absolute 0
787 .      ds www-percentage none\"
788 .      www-handle-percent \\$3 www-is-absolute www-absolute www-percentage
789 .      ie !\\n[www-is-absolute] \{\
790 .        \" percentage of pagelength requested
791 .        nr www-height (\\n[www-absolute] * \\n[.p] / 100)
792 .        if \\n[www-html] \
793 .           nr www-height (\\n[www-height] * 100 / 240)
794 .        ds www-size-specs "\\*[www-size-specs] height="\\*[www-percentage]"\"
795 .      \}
796 .      el \{\
797 .        nr www-height \\n[www-absolute]
798 .        if \\n[www-html] \
799 .           nr www-height (\\n[www-height] * 100 / 240)
800 .        ds www-size-specs "\\*[www-size-specs] height="\\*[www-height]"\"
801 .      \}
802 .    \}
803 .  \}
804 .  el \{\
805 .    \" height not specified; use width value
806 .    ie !\\n[www-is-absolute] \{\
807 .       \" percentage value
808 .       ds www-size-specs "\\*[www-size-specs] height="\\*[www-percentage]"\"
809 .       nr www-height \\n[www-width]
810 .    \}
811 .    el \{\
812 .       ds www-size-specs "\\*[www-size-specs] height="\\*[www-width]"\"
813 .       nr www-height \\n[www-width]
814 .    \}
815 .  \}
817 .  ie \\n[www-html] \{\
818 .    ie !\\n[www-image-just] \
819 .      HTML <img "src=""\\$1""" \
820                  "alt=""Image \\$1""" \
821                  "hspace=""\\n[www-htmlimage-gap]""" \
822                  "align=""right""" \
823                  "\\*[www-size-specs]\\*[www->]"
824 .    el \
825 .      HTML <img "src=""\\$1""" \
826                  "alt=""Image \\$1""" \
827                  "hspace=""\\n[www-htmlimage-gap]""" \
828                  "align=""left""" \
829                  "\\*[www-size-specs]\\*[www->]"
830 .  \}
831 .  el \{\
832 .    tm www-width is \\n[www-width]
833 .    tm www-height is \\n[www-height]
834 .    if !r ps4html \{\
835 .      www-make-unique-name
836 .      sy pngtopnm \\$1 \
837           | pnmcrop -white \
838           | @PNMTOPS_NOSETPAGE@ -noturn \
839           > \\*[www-unique-name].eps
840 .      ie !\\n[www-image-just] \{\
841 .        \" we must now disable a possible left image trap
842 .        sp -1
843 .        if (\\n[www-left-ll-trap] > 0) \
844 .          wh \\n[www-left-ll-trap]u
845 .        if (\\n[www-left-po-trap] > 0) \
846 .          wh \\n[www-left-po-trap]u
847 .        PSPIC -R \\*[www-unique-name].eps \\n[www-width]u \\n[www-height]u
848 .        sp -\\n[ps-desht]u
850 .        nr www-right-indent \\n[ps-deswid]u
851 .        \" we want to have some space between text and image,
852 .        \" so the line length must be shorter
853 .        ll -(\\n[www-right-indent]u + \\n[www-image-gap]u)
854 .        mk www-right-ll-trap
855 .        nr www-right-ll-trap +(\\n[ps-desht]u - 1v)
856 .        wh \\n[www-right-ll-trap]u www-finish-right-ll
858 .        \" now restore possible left trap
859 .        if (\\n[www-left-ll-trap] > 0) \
860 .          wh \\n[www-left-ll-trap]u www-finish-left-ll
861 .        if (\\n[www-left-po-trap] > 0) \
862 .          wh \\n[www-left-po-trap]u
863 .      \}
864 .      el \{\
865 .        \" we must now disable a possible right image trap
866 .        if (\\n[www-right-ll-trap] > 0) \
867 .          wh \\n[www-right-ll-trap]u
868 .        PSPIC -L \\*[www-unique-name].eps \\n[www-width]u \\n[www-height]u
869 .        sp -\\n[ps-desht]u
871 .        nr www-left-indent \\n[ps-deswid]u
872 .        \" increase offset by gap
873 .        po +(\\n[www-left-indent]u + \\n[www-image-gap]u)
874 .        \" decrease line length by gap
875 .        ll -(\\n[www-left-indent]u + \\n[www-image-gap]u)
876 .        mk www-left-ll-trap
877 .        nr www-left-ll-trap +(\\n[ps-desht]u - 1v)
878 .        wh \\n[www-left-ll-trap]u www-finish-left-ll
880 .        \" now restore possible right trap
881 .        if (\\n[www-right-ll-trap] > 0) \
882 .          wh \\n[www-right-ll-trap]u www-finish-right-ll
883 .      \}
884 .    \}
885 .  \}
888 .\" --------------------------------------------------------------------
889 .\" HnS n
891 .\"   Begin heading.  Heading level is N.
893 .\" HnE
895 .\"   End heading.
897 .\" If your heading contains URL, FTP, MTO macros you might wish to
898 .\" disable automatic links to headings.  This can be done via `-P-l'
899 .\" from the command line or by using a cakk to `.HX 0'.
901 .nr www-heading-no -1
903 .de HnS
904 .  ie '\\$1'' \
905 .    nr www-heading-no 1
906 .  el \
907 .    nr www-heading-no \\$1
908 .  DEVTAG-NH \\n[www-heading-no]
911 .de HnE
912 .  if (\\n[www-heading-no] == -1) \
913 .    www-error HnE found without a corresponding HnS
914 .  DEVTAG-EO-H
917 .\" --------------------------------------------------------------------
918 .\" LK
920 .\"   Emit the automatically collected links derived from
921 .\"   section/numbered headings at this position.
923 .de LK
924 .  DEVTAG .links
927 .\" --------------------------------------------------------------------
928 .\" HR
930 .\"   Produce a horizontal line.
932 .de HR
933 .  HTML</p> <hr\\*[www->]
936 .\" --------------------------------------------------------------------
937 .\" NHR
939 .\"  Suppress the generation of the top and bottom rules which grohtml
940 .\"  emits by default.
942 .de NHR
943 .  DEVTAG .no-auto-rule
947 .\" www-end-nowhere - end of input trap called to finish diversion.
949 .de www-end-nowhere
950 .  if !\\n[www-html] \
951 .    di
952 .  DEVTAG-EO-TL
955 .\" --------------------------------------------------------------------
956 .\" HTL
958 .\"   Generate an HTML title only.  This differs from the -ms .TL macro
959 .\"   which generates both an HTML title and an H1 heading.
961 .\"   This is useful when an author wishes to use an HTML title as search
962 .\"   engine fodder but a graphic title in the document.
964 .\"   The macro terminates when a space or break is seen (.sp, .br).
966 .de HTL
967 .  DEVTAG .html-tl
968 .  if !\\n[www-html] \
969 .    di www-nowhere
970 .  it 2 www-end-nowhere
973 .\" --------------------------------------------------------------------
974 .\" auxiliary definitions for lists
976 .ds www-ul-level1 \[bu]\ \ \"
977 .ds www-ul-level2 \[sq]\ \ \"
978 .ds www-ul-level3 \[ci]\ \ \"
979 .nr www-ul-level 0
981 .ds www-ol-level1 decimal\"
982 .ds www-ol-level2 lower-alpha\"
983 .ds www-ol-level3 lower-roman\"
984 .ds www-ol-tmp 00\ \ \"
985 .nr www-ol-ctr1 0 1
986 .nr www-ol-ctr2 0 1
987 .nr www-ol-ctr3 0 1
988 .af www-ol-ctr2 a
989 .af www-ol-ctr3 i
990 .nr www-ol-level 0
992 .nr www-dl-level 0
993 .nr www-dl-shift 5n
996 .\" allow nested lists
998 .nr www-depth 0
999 .nr www-li-indent \n[.i]
1000 .ds www-level0 nop\"
1001 .ds www-level1
1002 .ds www-level2
1003 .ds www-level3
1004 .ds www-level4
1005 .ds www-level5
1006 .ds www-level6
1007 .ds www-level7
1008 .ds www-level8
1009 .ds www-level9
1011 .\" which macro to use for LI
1012 .de www-push-li
1013 .  nr www-depth +1
1014 .  ds www-level\\n[www-depth] \\$1\"
1015 .  ds www-ltag\\n[www-depth]
1016 .  als LI \\$1
1019 .de www-pop-li
1020 .  nr www-depth -1
1021 .  als LI \\*[www-level\\n[www-depth]]
1024 .\" www-emit-ltag - shut down a previous open list tag
1025 .\"                 before issuing a new tag \\$1.
1026 .\"                 It then records tag \\$1 is open.
1028 .de www-emit-ltag
1029 .  if !'\\*[www-ltag\\n[www-depth]]'' \
1030 .    HTML-NS </\\*[www-ltag\\n[www-depth]]>
1031 .  if !'\\$1'' \
1032 .    HTML-NS <\\$1>
1033 .  ds www-ltag\\n[www-depth] \\$1\"
1037 .\" Auxiliary macro for ULS.
1039 .de www-push-ul-level
1040 .  nr www-ul-level +1
1041 .  if (\\n[www-ul-level] > 3) \
1042 .    www-error ULS: too many levels of indentation (\\n[www-ul-level])
1045 .\" Auxiliary macro for ULE.
1047 .de www-pop-ul-level
1048 .  if !\\n[www-ul-level] \
1049 .    www-error ULE: trying to terminate a list which does not exist
1050 .  nr www-ul-level -1
1054 .\" Auxiliary macro for OLS.
1056 .de www-push-ol-level
1057 .  nr www-ol-level +1
1058 .  if (\\n[www-ol-level] > 3) \
1059 .    www-error OLS: too many levels of indentation (\\n[www-ol-level])
1063 .\" Auxiliary macro for OLE.
1065 .de www-pop-ol-level
1066 .  if !\\n[www-ol-level] \
1067 .    www-error OLE: trying to terminate a list which does not exist
1068 .  nr www-ol-level -1
1071 .\" --------------------------------------------------------------------
1072 .\" ULS
1074 .\"   Start an unordered list.
1076 .de ULS
1077 .  www-push-li www-li-ul
1078 .  www-push-ul-level
1079 .  ie \\n[www-html] \{\
1080 .    www-emit-ltag
1081 .    HTML</p> <ul>
1082 .  \}
1083 .  el \
1084 .    nr www-li-indent +\w'\\*[www-ul-level\\n[www-ul-level]]'u
1087 .\" --------------------------------------------------------------------
1088 .\" ULE
1090 .\"   End an unordered list.
1092 .de ULE
1093 .  ie \\n[www-html] \{\
1094 .    www-emit-ltag
1095 .    HTML</p> </ul>
1096 .  \}
1097 .  el \{\
1098 .    nr www-li-indent -\w'\\*[www-ul-level\\n[www-ul-level]]'u
1099 .    in \\n[www-li-indent]u
1100 .  \}
1101 .  www-pop-ul-level
1102 .  www-pop-li
1105 .\" --------------------------------------------------------------------
1106 .\" OLS
1108 .\"   Start an ordered list.
1110 .de OLS
1111 .  www-push-li www-li-ol
1112 .  www-push-ol-level
1113 .  ie \\n[www-html] \{\
1114 .    www-emit-ltag
1115 .    HTML</p> <ol "style=""list-style-type:" \
1116                            "\\*[www-ol-level\\n[www-ol-level]]"">"
1117 .  \}
1118 .  el \
1119 .    nr www-li-indent +\w'\\*[www-ol-tmp]'u
1122 .\" --------------------------------------------------------------------
1123 .\" OLE
1125 .\"   End an ordered list.
1127 .de OLE
1128 .  ie \\n[www-html] \{\
1129 .    www-emit-ltag
1130 .    HTML </ol>
1131 .  \}
1132 .  el \{\
1133 .    nr www-li-indent -\w'\\*[www-ol-tmp]'u
1134 .    in \\n[www-li-indent]u
1135 .    nr www-ol-ctr\\n[www-ol-level] 0 1
1136 .  \}
1137 .  www-pop-ol-level
1138 .  www-pop-li
1141 .\" --------------------------------------------------------------------
1142 .\" DLS
1144 .\"   Start a definition list.
1146 .de DLS
1147 .  www-push-li www-li-dl
1148 .  nr www-dl-level +1
1149 .  ie \\n[www-html] \{\
1150 .    www-emit-ltag
1151 .    HTML</p> <dl>
1152 .  \}
1153 .  el \{\
1154 .    nr www-li-indent +\\n[www-dl-shift]u
1155 .    in \\n[www-li-indent]u
1156 .  \}
1159 .\" --------------------------------------------------------------------
1160 .\" DLE
1162 .\"   End a definition list.
1164 .de DLE
1165 .  ie \\n[www-html] \{\
1166 .    www-emit-ltag
1167 .    HTML </dl>
1168 .  \}
1169 .  el \{\
1170 .    nr www-li-indent -\\n[www-dl-shift]u
1171 .    in \\n[www-li-indent]u
1172 .  \}
1173 .  nr www-dl-level -1
1174 .  www-pop-li
1177 .\" --------------------------------------------------------------------
1178 .\" LI
1180 .\"   Insert a list item.
1183 .\" ********
1184 .\" www-li-ul - bulleted list item
1186 .de www-li-ul
1187 .  ie \\n[www-html] \
1188 .    www-emit-ltag li
1189 .  el \{\
1190 .    www:paraspace
1191 .    in \\n[www-li-indent]u
1192 .    ti -\w'\\*[www-ul-level\\n[www-ul-level]]'u
1193 .    nop \\*[www-ul-level\\n[www-ul-level]]\c
1194 .  \}
1197 .\" ********
1198 .\" www-li-ol - numbered list item
1200 .de www-li-ol
1201 .  ie \\n[www-html] \
1202 .    www-emit-ltag li
1203 .  el \{\
1204 .    www:paraspace
1205 .    in \\n[www-li-indent]u
1206 .    ti -\w'\\n[www-ol-ctr\\n[www-ol-level]]\ \ 'u
1207 .    nop \\n+[www-ol-ctr\\n[www-ol-level]]\ \ \c
1208 .  \}
1211 .\" ********
1212 .\" www-li-dl - definition list item
1214 .de www-li-dl
1215 .  ie \\n[www-html] \{\
1216 .    HTML <dt>\\$1</dt>
1217 .    www-emit-ltag dd
1218 .  \}
1219 .  el \{\
1220 .    www:paraspace
1221 .    in \\n[www-li-indent]u
1222 .    ti -\\n[www-dl-shift]u
1223 .    nop \&\\$1
1224 .    br
1225 .  \}
1228 .\" --------------------------------------------------------------------
1229 .\" DC l text [color]
1231 .\"   L is the letter to be dropped and enlarged.
1233 .\"   TEXT is the following text whose height the first letter should not
1234 .\"   exceed.
1236 .\"   COLOR is the optional color of the dropped letter (default black).
1238 .de DC
1239 .  ds www-dropcolor black\"
1240 .  if !'\\$3'' \
1241 .    ds www-dropcolor \\$3\"
1242 .  ie '\*[.T]'html' \{\
1243 .    www-make-unique-name
1244 .    nr www-drop-width (100u * \\n[.v]u * 3u / \\n[.l]u)
1245 .    MPIMG -L \\*[www-unique-name].png \\n[www-drop-width]%
1246 .  \}
1247 .  el \{\
1248 .    ie r ps4html \{\
1249 .      www-make-unique-name
1250 .      \" To avoid interferences with another DC macro call which is located
1251 .      \" very near to the current one, we draw the glyph on a separate page.
1252 .      \" Otherwise it could theoretically happen that the dropped capital
1253 .      \" glyphs overlap.
1254 .      bp
1255 .      ev www-DC
1256 .      vs 320p
1257 .      nop \O[5i\\*[www-unique-name].png]\O[1]
1258 .      nop \m[\\*[www-dropcolor]]\s[160]\O[3]\\$1\O[4]
1259 .      nop \O[2]\O[0]
1260 .      br
1261 .      ev
1262 .      bp
1263 .    \}
1264 .    el \{\
1265 .      ie n \
1266 .        nop \\$1\c
1267 .      el \{\
1268 .        nr dummy \w'\\$1'u
1269 .        nr dcht ((\\n[.v] + \\n[rst]) * \\n[.ps] / \\n[rst])
1270 .        char \[dcap] \m[\\*[www-dropcolor]]\s'\\n[dcht]u'\\$1
1271 .        nop \v'\\n[.v]u'\\[dcap]\v'-\\n[.v]u'\c
1272 '        ti \w'\\[dcap]'u
1273 .      \}
1274 .    \}
1275 .  \}
1276 .  nop \\$2
1280 .\" supplementary macros used by other macro sets
1282 .\" here are some tags specially for -Tps or -Thtml when invoked by
1283 .\" pre-html to generate PNG images from postscript.
1285 .\" --------------------------------------------------------------------
1286 .\" HTML-DO-IMAGE - tell troff to issue an image marker which can be
1287 .\"                 read back by pre-html
1289 .de HTML-DO-IMAGE
1290 .  if r ps4html \
1291 .    nop \O[5\\$2\\$1.png]\O[1]\O[3]
1292 .  if \\n[www-html] \
1293 .    nop \O[5\\$2\\$1.png]\O[0]\O[3]
1296 .\" --------------------------------------------------------------------
1297 .\" HTML-IMAGE-END - terminate an image for HTML
1299 .de HTML-IMAGE-END
1300 .  if r ps4html \
1301 .    nop \O[4]\O[2]\O[0]
1302 .  if \\n[www-html] \
1303 .    nop \O[4]\O[2]\O[1]
1306 .nr www-png-no 0
1308 .\" --------------------------------------------------------------------
1309 .\" www-make-unique-name - generate another unique name in string
1310 .\"                        `www-unique-name'
1312 .de www-make-unique-name
1313 .  nr www-png-no +1
1314 .  ds www-unique-name \\*[www-image-template]\\n[www-png-no]\"
1317 .\" --------------------------------------------------------------------
1318 .\" HTML-IMAGE and friends tell grohtml that this region of text needs
1319 .\"            to be rendered as an image.
1321 .de HTML-IMAGE
1322 .  \" generates a centered image
1323 .  www-make-unique-name
1324 .  HTML-DO-IMAGE \\*[www-unique-name] c
1327 .de HTML-IMAGE-RIGHT
1328 .  www-make-unique-name
1329 .  HTML-DO-IMAGE \\*[www-unique-name] r
1332 .de HTML-IMAGE-LEFT
1333 .  www-make-unique-name
1334 .  HTML-DO-IMAGE \\*[www-unique-name] l
1337 .de HTML-IMAGE-INLINE
1338 .  www-make-unique-name
1339 .  HTML-DO-IMAGE \\*[www-unique-name] i
1342 .\"  EQN-HTML-IMAGE and friends check to see whether the equation is
1343 .\"                 not in an image, in which case it allows HTML
1344 .\"                 (mathml) to be generated (if -Txhtml was specified).
1346 .de EQN-HTML-IMAGE
1347 .  \" generates a centered image
1348 .  www-make-unique-name
1349 .  EQN-HTML-DO-IMAGE \\*[www-unique-name] c
1352 .de EQN-HTML-IMAGE-RIGHT
1353 .  www-make-unique-name
1354 .  EQN-HTML-DO-IMAGE \\*[www-unique-name] r
1357 .de EQN-HTML-IMAGE-LEFT
1358 .  www-make-unique-name
1359 .  EQN-HTML-DO-IMAGE \\*[www-unique-name] l
1362 .de EQN-HTML-IMAGE-INLINE
1363 .  www-make-unique-name
1364 .  EQN-HTML-DO-IMAGE \\*[www-unique-name] i
1367 .\" --------------------------------------------------------------------
1368 .\" EQN-HTML-DO-IMAGE - tell troff to issue an image marker which can be
1369 .\"                     read back by pre-html
1371 .de EQN-HTML-DO-IMAGE
1372 .  ie r xhtml \{\
1373 .    if !(\\n[.O] == 0) \{\
1374 .      if r ps4html \
1375 .        nop \O[5\\$2\\$1.png]\O[1]\O[3]
1376 .      if \\n[www-html] \
1377 .        nop \O[5\\$2\\$1.png]\O[0]\O[3]
1378 .    \}
1379 .  \}
1380 .  el \
1381 .    HTML-DO-IMAGE \\$*
1384 .\" --------------------------------------------------------------------
1385 .\" EQN-HTML-IMAGE-END - terminate an image for HTML
1387 .de EQN-HTML-IMAGE-END
1388 .  ie r xhtml \{\
1389 .    if !(\\n[.O] == 0) \{\
1390 .      if r ps4html \
1391 .        nop \O[4]\O[2]\O[0]
1392 .      if \\n[www-html] \
1393 .        nop \O[4]\O[2]\O[1]
1394 .    \}
1395 .  \}
1396 .  el \
1397 .    HTML-IMAGE-END
1400 .\" --------------------------------------------------------------------
1401 .\" Setup around HTML-IMAGE and friends
1403 .\" now set up TS, TE, EQ, EN default macros
1405 .\" we must not use `.als': the definition of .TE in s.tmac, for example,
1406 .\" calls .HTML-IMAGE-END, which would refer to itself due to the alias,
1407 .\" causing an endless loop
1409 .if !d TS \{\
1410 .  de TS
1411 .    nop \\*[HTML-IMAGE]\\
1412 .  .
1414 .if !d TE \{\
1415 .  de TE
1416 .    nop \\*[HTML-IMAGE-END]\\
1417 .  .
1419 .if !d EQ \{\
1420 .  de EQ
1421 .    nop \\*[EQN-HTML-IMAGE]\\
1422 .  .
1424 .if !d EN \{\
1425 .  de EN
1426 .    nop \\*[EQN-HTML-IMAGE-END]\\
1427 .  .
1430 .\" --------------------------------------------------------------------
1431 .\" JOBNAME
1433 .\"   Generate multiple output files containing the HTML.
1434 .\"   A file is split whenever a .SH or .NH 1 is encountered.
1435 .\"   The argument to JOBNAME is the file stem for future output files.
1437 .de JOBNAME
1438 .  DEVTAG .job-name \\$1
1441 .\" --------------------------------------------------------------------
1442 .\" HEAD
1444 .\"   Add information to the <head> </head> section of the HTML
1445 .\"   document
1447 .de HEAD
1448 .  DEVTAG .head "\\$*"
1451 .\" --------------------------------------------------------------------
1452 .\" start of some code
1454 .de CDS
1455 .  ft C
1456 .  nf
1459 .\" --------------------------------------------------------------------
1460 .\" end of some code
1462 .de CDE
1463 .  fi
1464 .  ft P
1467 .ds www-nav-colour #eeeeee\"
1468 .nr www-nav-width-left 30
1469 .nr www-nav-width-right 70
1471 .\" --------------------------------------------------------------------
1472 .\" LNS - left navigation start
1474 .de LNS
1475 .  HTML</p> <table><tr><td "valign=""top""" \
1476                            "width=""\\n[www-nav-width-left]%""" \
1477                            "bgcolor=""\\*[www-nav-colour]"">"
1478 .  LK
1479 .  HTML</p> </td><td "valign=""top""" \
1480                      "width=""\\n[www-nav-width-right]%"">"
1481 .  nr SH-open 1
1484 .\" --------------------------------------------------------------------
1485 .\" LNE - left navigation end
1487 .de LNE
1488 .  HTML</p> </td></tr></table>
1489 .  HR
1492 .nr SH-open 0
1493 .nr needs-begin 0
1496 .\" some auxiliary macros for left navigation lists
1498 .de www-SH
1499 .  if (0\\$1 == 0) \{\
1500 .    if (\\n[SH-open] == 1) \
1501 .      LNE
1502 .    nr needs-begin 1
1503 .    @SH-old
1504 .  \}
1507 .de www-NH
1508 .  if (0\\$1 <= 1) \{\
1509 .    if (\\n[SH-open] == 1) \
1510 .      LNE
1511 .    nr needs-begin 1
1512 .    @NH-old
1513 .  \}
1516 .de www-LP
1517 .  @LP-old
1518 .  if (\\n[needs-begin] == 1) \{\
1519 .    HR
1520 .    LNS
1521 .  \}
1522 .  nr needs-begin 0
1525 .\" --------------------------------------------------------------------
1526 .\" ALN [colour] [left width percentage]
1528 .\"   Turn on automatic left navigation.  This macro should only be
1529 .\"   called once (normally at the start of the document) as it
1530 .\"   indicates that all top-level section headings form a navigation
1531 .\"   list on the left of the main text.
1533 .de ALN
1534 .  if '\*[.T]'html' \{\
1535 .    if !'\\$1'' \
1536 .      ds www-nav-colour \\$1\"
1537 .    if (0\\$2 > 0) \{\
1538 .      nr www-nav-width-left \\$2
1539 .      nr www-nav-width-right (100 - \\$2)
1540 .    \}
1541 .    rn @SH @SH-old
1542 .    rn www-SH @SH
1543 .    rn @NH @NH-old
1544 .    rn www-NH @NH
1545 .    rn @LP @LP-old
1546 .    rn www-LP @LP
1547 .  \}
1550 .\" --------------------------------------------------------------------
1551 .\" LINKSTYLE color [fontstyle [openglyph closeglyph]]
1553 .\"   Initialize www.tmac so that when this macro set is used with
1554 .\"   non-HTML devices the urls are rendered the user defined attributes.
1555 .\"   For example:
1557 .\"   LINKSTYLE blue CR < >
1559 .de LINKSTYLE
1560 .  if (\\n[.$] < 1) \
1561 .    www:error .\\$0 expects at least 1 argument.
1562 .  ds www:color \\$1\"
1563 .  shift
1564 .  if (\\n[.$] < 1) \
1565 .    return
1566 .  ds www:fontstyle \\$1\"
1567 .  shift
1568 .  if (\\n[.$] < 1) \
1569 .    www:error .\\$0 expects that both the open and close glyph is specified
1570 .  ds www:open \\$1\"
1571 .  ds www:close \\$2\"
1574 .\" MATHML - enable eqn mathml output to pass through to the device
1575 .\"          driver
1577 .de MATHML
1578 .  if (\\n[.O] == 0) \
1579 .    MATH<?p> \\$*
1582 .\" --------------------------------------------------------------------
1583 .\" final setup
1584 .\" --------------------------------------------------------------------
1586 .LINKSTYLE blue C \[la] \[ra]
1588 .if \n[www-html] \{\
1589 .  nh
1590 .  nr HY 0
1593 .if r ps4html .nop \O[0]
1594 .cp \n(_C
1596 .\" now set
1598 .\" --------------------------------------------------------------------
1599 .\" Emacs settings
1600 .\" --------------------------------------------------------------------
1602 .\" Local Variables:
1603 .\" mode: nroff
1604 .\" End:
1605 .\" EOF