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