* tmac/devtag.tmac: Protect against loading twice.
[s-roff.git] / tmac / www.tmac
blob1f4da764d0c0273221d728a0d77c0931b2a56e0d
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 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
527 .\" --------------------------------------------------------------------
528 .\" MPIMG [-R|-L] [-G gap] filename [width [height]]
530 .\"   Include a png image and wrap text around it.  It will work for
531 .\"   -Tps and -Thtml.  The default value for WIDTH is 1i; default value
532 .\"   for HEIGHT is WIDTH; the default alignment is left (-L).
533 .\"   -G is used to insert a gap between the text and the image.
535 .\" Note: This macro can only be used with the `-U' option of groff,
536 .\"       activating unsafe mode, if not used with -Thtml; the PNG image
537 .\"       is then converted to the EPS format using netpbm utilities.
540 .nr www-htmlimage-gap 0
542 .de MPIMG
543 .  nr www-image-just 1
544 .  nr www-image-gap 0
545 .  while (\\n[.$] > 0) \{\
546 .    if '-L'\\$1' \{\
547 .      nr www-image-just 1
548 .      shift
549 .      continue
550 .    \}
551 .    if '-R'\\$1' \{\
552 .      nr www-image-just 0
553 .      shift
554 .      continue
555 .    \}
556 .    if '-G'\\$1' \{\
557 .      nr www-image-gap \\$2
558 .      nr www-htmlimage-gap (\\$2 * 100 / 240)
559 .      shift 2
560 .      continue
561 .    \}
562 .    break
563 .  \}
564 .  nr www-width 1i
565 .  if !'\\$2'' \
566 .    nr www-width \\$2
567 .  nr www-height \\n[www-width]
568 .  if !'\\$3'' \
569 .    nr www-height \\$3
570 .  nr www-width (\\n[www-width] * 100 / 240)
571 .  nr www-height (\\n[www-height] * 100 / 240)
573 .  ie \\n[www-html] \{\
574 .    ie !\\n[www-image-just] \
575 .      HTML <img src="\\$1" alt="Image \\$1" hspace=\\n[www-htmlimage-gap] \
576              align=right width=\\n[www-width] height=\\n[www-height]>
577 .    el \
578 .      HTML <img src="\\$1" alt="Image \\$1" hspace=\\n[www-htmlimage-gap] \
579              align=left width=\\n[www-width] height=\\n[www-height]>
580 .  \}
581 .  el \{\
582 .    if !r ps4html \{\
583 .      www-make-unique-name
584 .      sy pngtopnm \\$1 | pnmcrop -white | @PNMTOPS_NOSETPAGE@ -noturn > \\*[www-unique-name].eps
585 .      ie !\\n[www-image-just] \{\
586 .        \" we must now disable a possible left image trap
587 .        sp -1
588 .        if (\\n[www-left-ll-trap] > 0) \
589 .          wh \\n[www-left-ll-trap]u
590 .        if (\\n[www-left-po-trap] > 0) \
591 .          wh \\n[www-left-po-trap]u
592 .        PSPIC -R \\*[www-unique-name].eps \\$2 \\$3
593 .        sp -\\n[ps-desht]u
594 .        nr www-right-indent \\n[ps-deswid]u
595 .        \" we want to have some space between text and image,
596 .        \" so the line length must be shorter
597 .        ll -(\\n[www-right-indent]u + \\n[www-image-gap]u)
598 .        mk www-right-ll-trap
599 .        nr www-right-ll-trap +(\\n[ps-desht]u - 1v)
600 .        wh \\n[www-right-ll-trap]u www-finish-right-ll
601 .        \" now restore possible left trap
602 .        if (\\n[www-left-ll-trap] > 0) \
603 .          wh \\n[www-left-ll-trap]u www-finish-left-ll
604 .        if (\\n[www-left-po-trap] > 0) \
605 .          wh \\n[www-left-po-trap]u
606 .      \}
607 .      el \{\
608 .        \" we must now disable a possible right image trap
609 .        if (\\n[www-right-ll-trap] > 0) \
610 .          wh \\n[www-right-ll-trap]u
611 .        PSPIC -L \\*[www-unique-name].eps \\$2 \\$3
612 .        sp -\\n[ps-desht]u
613 .        nr www-left-indent \\n[ps-deswid]u
614 .        \" increase offset by gap
615 .        po +(\\n[www-left-indent]u + \\n[www-image-gap]u)
616 .        \" decrease line length by gap
617 .        ll -(\\n[www-left-indent]u + \\n[www-image-gap]u)
618 .        mk www-left-ll-trap
619 .        nr www-left-ll-trap +(\\n[ps-desht]u - 1v)
620 .        wh \\n[www-left-ll-trap]u www-finish-left-ll
621 .        \" now restore possible right trap
622 .        if (\\n[www-right-ll-trap] > 0) \
623 .          wh \\n[www-right-ll-trap]u www-finish-right-ll
624 .      \}
625 .    \}
626 .  \}
628 .\" --------------------------------------------------------------------
629 .\" HnS n
631 .\"   Begin heading.  Heading level is N.
633 .\" HnE
635 .\"   End heading.
637 .\" If your heading contains URL, FTP, MTO macros you might wish to
638 .\" disable automatic links to headings.  This can be done via `-P-l'
639 .\" from the command line or by using a cakk to `.HX 0'.
641 .nr www-heading-no -1
643 .de HnS
644 .  ie '\\$1'' \
645 .    nr www-heading-no 1
646 .  el \
647 .    nr www-heading-no \\$1
648 .  DEVTAG-NH \\n[www-heading-no]
651 .de HnE
652 .  if (\\n[www-heading-no] == -1) \
653 .    www-error "HnE found without a corresponding HnS"
654 .  DEVTAG-EO-H
656 .\" --------------------------------------------------------------------
657 .\" LK
659 .\"   Emit the automatically collected links derived from
660 .\"   section/numbered headings at this position.
662 .de LK
663 .  DEVTAG ".links"
665 .\" --------------------------------------------------------------------
666 .\" HR
668 .\"   Produce a horizontal line.
670 .de HR
671 .  HTML</p> "<hr>"
673 .\" --------------------------------------------------------------------
674 .\" NHR
676 .\"  Suppresses the generation of the top and bottom rules which grohtml
677 .\"  emits by default.
679 .de NHR
680 .  DEVTAG ".no-auto-rule"
683 .\" www-end-nowhere - end of input trap called to finish diversion.
685 .de www-end-nowhere
686 .  if !\\n[www-html] \
687 .    di
688 .  DEVTAG-EO-TL
690 .\" --------------------------------------------------------------------
691 .\" HTL
693 .\"   Generate an HTML title only.  This differs from the -ms .TL macro
694 .\"   which generates both an HTML title and an H1 heading.
696 .\"   This is useful when an author wishes to use a HTML title as search
697 .\"   engine fodder but a graphic title in the document.
699 .\"   The macro terminates when a space or break is seen (.sp, .br).
701 .de HTL
702 .  DEVTAG ".html-tl"
703 .  if !\\n[www-html] \
704 .    di www-nowhere
705 .  it 2 www-end-nowhere
708 .\" --------------------------------------------------------------------
709 .\" auxiliary definitions for ULS / ULE
711 .ds www-level1 \[bu]\ \ \"
712 .ds www-level2 \[sq]\ \ \"
713 .ds www-level3 \[ci]\ \ \"
714 .nr www-level 0
715 .nr www-depth 0
718 .\" Auxiliary macro for ULS.
720 .de www-push-level
721 .  nr www-level +1
722 .  if (\\n[www-level] > 3) \
723 .    www-error "too many levels of indentation (\\n[www-level])"
726 .\" Auxiliary macro for ULE.
728 .de www-pop-level
729 .  if !\\n[www-level] \
730 .    www-error "trying to terminate a list which does not exist"
731 .  nr www-level -1
733 .\" --------------------------------------------------------------------
734 .\" ULS
736 .\"   Start an unordered list.
738 .de ULS
739 .  www-push-level
740 .  ie \\n[www-html] \
741 .    HTML</p> "<ul>"
742 .  el \{\
743 .    if (\\n[www-level] == 1) \
744 .      nr www-depth \\n[.i]
745 .    nr www-depth +\w'\\*[www-level\\n[www-level]]'u
746 .  \}
748 .\" --------------------------------------------------------------------
749 .\" ULE
751 .\"   End an unordered list.
753 .de ULE
754 .  ie \\n[www-html] \
755 .    HTML</p> "</ul>"
756 .  el \{\
757 .    nr www-depth -\w'\\*[www-level\\n[www-level]]'u
758 .    in \\n[www-depth]u
759 .  \}
760 .  www-pop-level
762 .\" --------------------------------------------------------------------
763 .\" LI
765 .\"   Insert a list item.
767 .de LI
768 .  ie \\n[www-html] \
769 .    HTML</p> "<li>"
770 .  el \{\
771 .    www:paraspace
772 .    in \\n[www-depth]u
773 .    ti -\w'\\*[www-level\\n[www-level]]'u
774 .    nop \\*[www-level\\n[www-level]]\c
775 .  \}
777 .\" --------------------------------------------------------------------
778 .\" DC l text [color]
780 .\"   L is the letter to be dropped and enlarged.
782 .\"   TEXT is the following text whose height the first letter should not
783 .\"   exceed.
785 .\"   COLOR is the optional color of the dropped letter (default black).
787 .de DC
788 .  ds www-dropcolor black
789 .  if !'\\$3'' \
790 .    ds www-dropcolor \\$3
791 .  ie '\*(.T'html' \{\
792 .    www-make-unique-name
793 .    MPIMG -L \\*[www-unique-name].png "(\\n[.v] * 2u)"
794 .  \}
795 .  el \{\
796 .    ie r ps4html \{\
797 .      www-make-unique-name
798 .      \" To avoid interferences with another DC macro call which is located
799 .      \" very near to the current one, we draw the glyph on a separate page.
800 .      \" Otherwise it could theoretically happen that the dropped capital
801 .      \" glyphs overlap.
802 .      bp
803 .      ev www-DC
804 .      vs 80p
805 .      nop \O[5i\\*[www-unique-name].png]\O[1]
806 .      nop \m[\\*[www-dropcolor]]\s[40]\O[3]\\$1\O[4]
807 .      nop \O[2]\O[0]
808 .      br
809 .      ev
810 .      bp
811 .    \}
812 .    el \{\
813 .      ie n \
814 .        nop \\$1\c
815 .      el \{\
816 .        nr dummy \w'\\$1'u
817 .        nr dcht ((\\n[.v] + \\n[rst]) * \\n[.ps] / \\n[rst])
818 .        char \[dcap] \m[\\*[www-dropcolor]]\s'\\n[dcht]u'\\$1
819 .        nop \v'\\n[.v]u'\\[dcap]\v'-\\n[.v]u'\c
820 '        ti \w'\\[dcap]'u
821 .      \}
822 .    \}
823 .  \}
824 .  nop \\$2
826 .\" --------------------------------------------------------------------
827 .\" Setup around HTML-IMAGE and friends
829 .\" now set up TS, TE, EQ, EN default macros
831 .do if !d TS .do ds TS HTML-IMAGE
832 .do if !d TE .do ds TE HTML-IMAGE-END
833 .do if !d EQ .do ds EQ HTML-IMAGE
834 .do if !d EN .do ds EN HTML-IMAGE-END
836 .\" supplementary macros used by other macro sets
838 .\" here are some tags specially for -Tps or -Thtml when invoked by
839 .\" pre-html to generate png images from postscript.
841 .\" --------------------------------------------------------------------
842 .\" HTML-DO-IMAGE - tells troff to issue an image marker which can be
843 .\"                 read back by pre-html
845 .de HTML-DO-IMAGE
846 .  if r ps4html \
847 .    nop \O[5\\$2\\$1.png]\O[1]\O[3]
848 .  if \\n[www-html] \
849 .    nop \O[5\\$2\\$1.png]\O[0]\O[3]
851 .\" --------------------------------------------------------------------
852 .\" HTML-IMAGE-END - terminates an image for html
854 .de HTML-IMAGE-END
855 .  if r ps4html \
856 .    nop \O[4]\O[2]\O[0]
857 .  if \\n[www-html] \
858 .    nop \O[4]\O[2]\O[1]
861 .nr www-png-no 0
863 .\" --------------------------------------------------------------------
864 .\" www-make-unique-name - generates another unique name in string
865 .\"                        `www-unique-name'
867 .de www-make-unique-name
868 .  nr www-png-no +1
869 .  ds www-unique-name \\*[www-image-template]\\n[www-png-no]
871 .\" --------------------------------------------------------------------
872 .\" HTML-IMAGE and friends tell grohtml that this region of text needs
873 .\"            to be rendered as an image.
875 .de HTML-IMAGE
876 .  \" generates a centered image
877 .  www-make-unique-name
878 .  HTML-DO-IMAGE \\*[www-unique-name] c
881 .de HTML-IMAGE-RIGHT
882 .  www-make-unique-name
883 .  HTML-DO-IMAGE \\*[www-unique-name] r
886 .de HTML-IMAGE-LEFT
887 .  www-make-unique-name
888 .  HTML-DO-IMAGE \\*[www-unique-name] l
891 .de HTML-IMAGE-INLINE
892 .  www-make-unique-name
893 .  HTML-DO-IMAGE \\*[www-unique-name] i
896 .\" --------------------------------------------------------------------
897 .\" JOBNAME
899 .\"   Generate multiple output files containing the html.
900 .\"   A file is split whenever a .SH or .NH 1 is encountered.
901 .\"   The argument to JOBNAME is the file stem for future output files.
903 .de JOBNAME
904 .  DEVTAG .job-name \\$1
906 .\" --------------------------------------------------------------------
907 .\" HEAD
909 .\"   Adds information to the <head> </head> section of the html
910 .\"   document
911 .\" --------------------------------------------------------------------
912 .de HEAD
913 .  DEVTAG .head "\\$*"
915 .\" --------------------------------------------------------------------
916 .\" Final Setup
917 .\" --------------------------------------------------------------------
919 .if \n[www-html] \{\
920 .   nh
921 .   nr HY 0
925 .\" start of some code
928 .de CDS
929 .ft C
933 .\" end of some code
936 .de CDE
938 .ft P
941 .if r ps4html .nop \O[0]
942 .cp \n(_C
944 .\" now set
946 .\" --------------------------------------------------------------------
947 .\" Emacs settings
948 .\" --------------------------------------------------------------------
950 .\" Local Variables:
951 .\" mode: nroff
952 .\" End:
953 .\" EOF