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