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