PageRenderTime 36ms CodeModel.GetById 7ms app.highlight 22ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/groff/tmac/www.tmac

https://bitbucket.org/freebsd/freebsd-head/
Unknown | 1230 lines | 1220 code | 10 blank | 0 comment | 0 complexity | 8421ae1c46e75ba47645d9a82034a078 MD5 | raw file
   1.ig
   2www.tmac - macro package for adding HTML elements to roff documents.
   3
   4File position: <groff_source_top>/tmac/www.tmac
   5Installed position: groff's main macro directory.
   6
   7------------------------------------------------------------------------
   8    Legalize
   9------------------------------------------------------------------------
  10
  11This file is part of groff, the GNU roff type-setting system.
  12
  13Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
  14written by Gaius Mulley <gaius@glam.ac.uk>, with additions by
  15Werner Lemberg <wl@gnu.org> and Bernd Warken <bwarken@mayn.de>.
  16
  17groff is free software; you can redistribute it and/or modify it under
  18the terms of the GNU General Public License as published by the Free
  19Software Foundation; either version 2, or (at your option) any later
  20version.
  21
  22groff is distributed in the hope that it will be useful, but WITHOUT
  23ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  24FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  25for more details.
  26
  27You should have received a copy of the GNU General Public License
  28along with groff; see the file COPYING.  If not, write to the Free
  29Software Foundation, 51 Franklin St - Fifth Floor, Boston, MA
  3002110-1301, USA.
  31
  32
  33------------------------------------------------------------------------
  34    Description
  35------------------------------------------------------------------------
  36
  37A simple set of macros to provide HTML documents with basic
  38www functionality.  It should work with any macro set.
  39..
  40.
  41.\" --------------------------------------------------------------------
  42.\" Setup
  43.\" --------------------------------------------------------------------
  44.
  45.do if d www:lenstr .nx
  46.
  47.do mso devtag.tmac
  48.
  49.nr _C \n(.C
  50.cp 0
  51.
  52.
  53.nr www-html 0
  54.if '\*[.T]'html' .nr www-html 1
  55.
  56.\" set up www-image-template
  57.
  58.if !d www-image-template \
  59.  ds www-image-template
  60.
  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.\}
  71.
  72.
  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
 102..
 103.www:@test_substring
 104.rm www:@test_substring
 105.
 106.
 107.\" --------------------------------------------------------------------
 108.\" Local Macros
 109.\" --------------------------------------------------------------------
 110.
 111.\" --------------------------------------------------------------------
 112.\" www:paraspace
 113.\"
 114.\" Space before paragraph. Use \n[PD] if it exists.
 115.\"
 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
 120..
 121.
 122.\"
 123.\" --------------------------------------------------------------------
 124.\" www:error (<test>...)
 125.\"
 126.\" Print error message
 127.\"
 128.de www-error
 129.  tm \\n[.F]:\\n[.c]: macro error: \\$*
 130..
 131.als www:error www-error
 132.
 133.\" --------------------------------------------------------------------
 134.\" www:lenstr (<register_name> <string_name>)
 135.\"
 136.\" Store length of string named <string_name> into register named
 137.\" <register_name>.
 138.\"
 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
 147..
 148.\" --------------------------------------------------------------------
 149.\" www:splitstr (<name>)
 150.\"
 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'.
 154.\"
 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
 182..
 183.\" --------------------------------------------------------------------
 184.\" www:url_breaks (<string_name>)
 185.\"
 186.\" Add `\:' (possible break point) within URL strings after `/'.
 187.\"
 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.
 191.\"
 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
 202..
 203.\" --------------------------------------------------------------------
 204.\" www:url_breaks_splitted (<result> <char> [<char>...])
 205.\"
 206.\" Add `\:' within URL strings, but arguments are a splitted string.
 207.\"
 208.\" Arguments: >=2: <result> <char> [<char>...]
 209.\"
 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
 258..
 259.\" --------------------------------------------------------------------
 260.\" User Interface
 261.\" --------------------------------------------------------------------
 262.
 263.\" --------------------------------------------------------------------
 264.\" HTML
 265.\"
 266.\" the main auxiliary macro for the HTML interface
 267.\"
 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.  \}
 279..
 280.\"
 281.\" an auxiliary macro for HTML (without following space)
 282.\"
 283.de HTML-NS
 284.  nop \X^html:\\$*^\c
 285..
 286.\"
 287.\" emit a HTML tag after shutting down a (possibly open) paragraph
 288.\"
 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.  \}
 294..
 295.\" --------------------------------------------------------------------
 296.\" HX n
 297.\"
 298.\"   Automatic heading level cut off.
 299.\"
 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'.
 303.\"
 304.de HX
 305.  if \\n[www-html] \
 306.    nop \X^index:\\$*^
 307..
 308.\" --------------------------------------------------------------------
 309.\" BCL foreground background active not-visited visited
 310.\"
 311.de BCL
 312.  HTML <body text=\\$1 bgcolor=\\$2 link=\\$3 alink=\\$4 vlink=\\$5>
 313..
 314.\" --------------------------------------------------------------------
 315.\" BGIMG imagefile
 316.\"
 317.de BGIMG
 318.  HTML <body background=\\$1>
 319..
 320.\" --------------------------------------------------------------------
 321.\" URL url [description] [after]
 322.\"     if description is absent then the url becomes the anchor text
 323.\"
 324.de URL
 325.  ie !'\\$1'' \{\
 326.    ds \\$0:adr \\$1\"
 327.    www:url_breaks \\$0:adr
 328.  \}
 329.  ie \\n[www-html] \{\
 330.    ie '\\$3'' \
 331.      ds \\$0:after \&
 332.    el \
 333.      ds \\$0:after \&\\$3
 334.    ie '\\$2'' \
 335.       HTML-NS <a href="\\$1">\\$1</a>
 336.    el \
 337.       HTML-NS <a href="\\$1">\\$2</a>
 338.    nop \\*[\\$0:after]
 339.    rm \\$0:after
 340.  \}
 341.  el \{\
 342.    if !r ps4html .ad l
 343.    ie '\\$2'' \{\
 344.      ie '\\$1'' \{\
 345.        ie !'\\$3'' \
 346.          nop \\$3
 347.      \}
 348.      el \{\
 349.        ie \\n[.color] \
 350.          nop \%\[la]\m[blue]\f[C]\\*[\\$0:adr]\f[]\m[]\[ra]\\$3
 351.        el \
 352.          nop \%\[la]\f[CB]\\*[\\$0:adr]\f[]\[ra]\\$3
 353.      \}
 354.    \}
 355.    el \{\
 356.      ie '\\$1'' \{\
 357.        ie \\n[.color] \
 358.          nop \m[blue]\\$2\m[]\\$3
 359.        el \
 360.          nop \f[B]\\$2\f[]\\$3
 361.      \}
 362.      el \{\
 363.        ie \\n[.color] \
 364.          nop \m[blue]\\$2\m[] \%\[la]\f[C]\\*[\\$0:adr]\f[]\[ra]\\$3
 365.        el \
 366.          nop \f[B]\\$2\f[] \%\[la]\f[C]\\*[\\$0:adr]\f[]\[ra]\\$3
 367.      \}
 368.    \}
 369.    if !r ps4html .ad
 370.  \}
 371.  rm \\$0:adr
 372..
 373.\" --------------------------------------------------------------------
 374.\" FTP url description [after]
 375.\"
 376.\"   Same as URL.
 377.\"
 378.als FTP URL
 379.\" --------------------------------------------------------------------
 380.\" MTO address description [after]
 381.\"
 382.\"   ADDRESS is the email address (without the `mailto:' prefix).
 383.\"
 384.\"   DESCRIPTION is the optional name.  If an empty argument is given,
 385.\"   ADDRESS is used instead.
 386.\"
 387.\"   AFTER is optional stuff printed immediately after ADDRESS
 388.\"   (resp. DESCRIPTION).
 389.\"
 390.\"     Example:
 391.\"
 392.\"       Foobar has been written by
 393.\"       .MTO fred@foo.bar "Fredrick Bloggs" .
 394.\"
 395.de MTO
 396.  ie \\n[www-html] \{\
 397.    ie '\\$2'' \
 398.      URL mailto:\\$1 \\$1 "\\$3"
 399.    el \
 400.      URL mailto:\\$1 "\\$2" "\\$3"
 401.  \}
 402.  el \{\
 403.    ie '\\$2'' \{\
 404.      ie '\\$1'' \{\
 405.        ie !'\\$3'' \
 406.          nop \\$3
 407.      \}
 408.      el \{\
 409.        ie \\n[.color] \
 410.          nop \%\m[blue]\f[C]\\$1\f[]\m[]\\$3
 411.        el \
 412.          nop \%\f[CB]\\$1\f[]\\$3
 413.      \}
 414.    \}
 415.    el \{\
 416.      ie '\\$1'' \{\
 417.        ie \\n[.color] \
 418.          nop \m[blue]\\$2\m[]\\$3
 419.        el \
 420.          nop \f[B]\\$2\f[]\\$3
 421.      \}
 422.      el \{\
 423.        ie \\n[.color] \
 424.          nop \m[blue]\\$2\m[] \%\[la]\f[C]\\$1\f[]\[ra]\\$3
 425.        el
 426.          nop \f[B]\\$2\f[] \%\[la]\f[C]\\$1\f[]\[ra]\\$3
 427.      \}
 428.    \}
 429.  \}
 430..
 431.\" --------------------------------------------------------------------
 432.\" TAG name
 433.\"
 434.\"   Generate an html name NAME.
 435.\"
 436.de TAG
 437.  HTML <a name="\\$1"></a>
 438..
 439.\" --------------------------------------------------------------------
 440.\" IMG [-R|-L|-C] filename [width] [height]
 441.\"
 442.\"   Include an image of any type (will only work for -Thtml).
 443.\"
 444.\"   Alignment is centered by default (-C).
 445.\"   Default value for WIDTH is 1i.
 446.\"   If HEIGHT is not given, WIDTH is used as the height.
 447.\"
 448.de IMG
 449.  ie \\n[www-html] \{\
 450.    ie '\\$2'-R' \
 451.      DEVTAG ".right-image"
 452.    el \{\
 453.      ie '\\$2'-L' \
 454.        DEVTAG ".left-image"
 455.      el \
 456.        DEVTAG ".centered-image"
 457.    \}
 458.    nr www-width 100
 459.    if !'\\$3'' \
 460.      nr www-width \\$3
 461.    nr www-height \\n[www-width]
 462.    if !'\\$4'' \
 463.      nr www-height \\$4
 464.    HTML <img src="\\$1" alt="Image \\$1" \
 465           width=\\n[www-width] height=\\n[www-height]>
 466.  \}
 467.  el \
 468.    nop \[la]\f[C]\\$1\f[]\[ra]
 469..
 470.\" --------------------------------------------------------------------
 471.\" PIMG  [-R|-L|-C] filename [width] [height]
 472.\"
 473.\"   Include a png image.  It will work for -Tps and -Thtml.
 474.\"   The default value for WIDTH and HEIGHT is zero; the default
 475.\"   alignment is centering (-C).
 476.\"
 477.\" Note: This macro can only be used with the `-U' option of groff,
 478.\"       activating unsafe mode, if not used with -Thtml; the PNG image
 479.\"       is then converted to the EPS format using netpbm utilities.
 480.\"
 481.de PIMG
 482.  ie \\n[www-html] \{\
 483.    ie '\\$1'-R' \
 484.      DEVTAG ".right-image"
 485.    el \{\
 486.      ie '\\$1'-L' \
 487.        DEVTAG ".left-image"
 488.      el \
 489.        DEVTAG ".centered-image"
 490.    \}
 491.    nr www-width 0
 492.    nr www-height 0
 493.    if !'\\$3'' \
 494.      nr www-width (\\$3 * 100 / 240)
 495.    if !'\\$4'' \
 496.      nr www-height (\\$4 * 100 / 240)
 497.    ie (\\n[www-width] == 0) \{\
 498.      ie (\\n[www-height] == 0) \
 499.        HTML <img src="\\$2" alt="Image \\$2">
 500.      el \
 501.        HTML <img src="\\$1" alt="Image \\$2" height=\\n[www-height]>
 502.    \}
 503.    el \{\
 504.      ie (\\n[www-height] == 0) \
 505.        HTML <img src="\\$2" alt="Image \\$2" width=\\n[www-width]>
 506.      el \
 507.        HTML <img src="\\$2" alt="Image \\$2" width=\\n[www-width] \
 508               height=\\n[www-height]>
 509.    \}
 510.  \}
 511.  el \{\
 512.    if !r ps4html \{\
 513.      www-make-unique-name
 514.      sy pngtopnm \\$2 | pnmcrop -white | @PNMTOPS_NOSETPAGE@ -noturn > \\*[www-unique-name].eps
 515.      ie '\\$1'-C' \
 516.        PSPIC \\*[www-unique-name].eps \\$3 \\$4
 517.      el \
 518.        PSPIC \\$1 \\*[www-unique-name].eps \\$3 \\$4
 519.    \}
 520.  \}
 521..
 522.
 523.\" --------------------------------------------------------------------
 524.\" auxiliary definitions for MPIMG
 525.\"
 526.nr www-left-ll-trap 0
 527.nr www-left-po-trap 0
 528.nr www-right-ll-trap 0
 529.
 530.de www-finish-left-po
 531.  po -(\\n[www-left-indent]u + \\n[www-image-gap]u)
 532.  wh \\n[www-left-po-trap]u
 533.  nr www-left-indent 0
 534..
 535.
 536.\" called when the -R picture is finished
 537.de www-finish-right-ll
 538.  ll +(\\n[www-right-indent]u + \\n[www-image-gap]u)
 539.  \" now see whether we need to inline www-finish-left-ll
 540.  if (\\n[www-left-ll-trap]u > 0) \
 541.    if ((\\n[www-right-ll-trap]u + 1v) >= \\n[www-left-ll-trap]u) \{\
 542.      mk www-left-po-trap
 543.      nr www-left-po-trap +1v
 544.      wh \\n[www-left-po-trap]u www-finish-left-po
 545.      ll +\\n[www-left-indent]u
 546.      wh \\n[www-left-ll-trap]u
 547.      nr www-left-ll-trap 0
 548.    \}
 549.  \" and see whether we need to inline www-finish-left-po
 550.  if (\\n[www-left-po-trap]u > 0) \
 551.    if ((\\n[www-right-ll-trap]u + 1v) >= \\n[www-left-po-trap]u) \{\
 552.      po -\\n[www-left-indent]u
 553.      wh \\n[www-left-po-trap]u
 554.      nr www-left-indent 0
 555.    \}
 556.  wh \\n[www-right-ll-trap]u
 557.  nr www-right-ll-trap 0
 558..
 559.
 560.de www-finish-left-ll
 561.  if (\\n[www-right-ll-trap] > 0) \
 562.    if ((\\n[www-left-ll-trap] + 1v) >= \\n[www-right-ll-trap]) \{\
 563.      ll +\\n[www-right-indent]u
 564.      nr www-right-ll-trap 0
 565.    \}
 566.  mk www-left-po-trap
 567.  nr www-left-po-trap +1v
 568.  wh \\n[www-left-po-trap]u www-finish-left-po
 569.  ll +(\\n[www-left-indent]u + \\n[www-image-gap]u)
 570.  wh \\n[www-left-ll-trap]u
 571.  nr www-left-ll-trap 0
 572..
 573.
 574.\" www-handle-percent arg N1 N2 S1
 575.\"                    arg - input string (number or number%)
 576.\"                    output parameters:
 577.\"                    N1 - name of number register 1=absolute 0=percentage
 578.\"                    N2 - number register name for absolute value
 579.\"                    S1 - string register name for percentage value
 580.
 581.de www-handle-percent 
 582.  ds www-percent \\$1\"
 583.  substring www-percent -1 -1
 584.
 585.  ie '\\*[www-percent]'%' \{\
 586.    ds www-abs \\$1\"
 587.    substring www-abs 0 -2
 588.    nr \\$2 0
 589.    nr \\$3 \\*[www-abs]
 590.    ds \\$4 \\$1\"
 591.  \}
 592.  el \{\
 593.    nr \\$2 1
 594.    nr \\$3 \\$1
 595.    ds \\$4 none\"
 596.  \}
 597..
 598.
 599.\" --------------------------------------------------------------------
 600.\" MPIMG [-R|-L] [-G gap] filename [width [height]]
 601.\"
 602.\"   Include a png image and wrap text around it.  It will work for
 603.\"   -Tps and -Thtml.  The default value for WIDTH is 1i; default value
 604.\"   for HEIGHT is WIDTH; the default alignment is left (-L).
 605.\"   -G is used to insert a gap between the text and the image.
 606.\"   The height and width can also be given as a percentage.
 607.\"   The PostScript device converts the percentage width into an
 608.\"   absolute value by using \\n[.l], and the height by using \\n[.p].
 609.\"   
 610.\"
 611.\" Note: This macro can only be used with the `-U' option of groff,
 612.\"       activating unsafe mode, if not used with -Thtml; the PNG image
 613.\"       is then converted to the EPS format using netpbm utilities.
 614.\"
 615.
 616.nr www-htmlimage-gap 0
 617.
 618.de MPIMG
 619.  nr www-image-just 1
 620.  nr www-image-gap 0
 621.  while (\\n[.$] > 0) \{\
 622.    if '-L'\\$1' \{\
 623.      nr www-image-just 1
 624.      shift
 625.      continue
 626.    \}
 627.    if '-R'\\$1' \{\
 628.      nr www-image-just 0
 629.      shift
 630.      continue
 631.    \}
 632.    if '-G'\\$1' \{\
 633.      nr www-image-gap \\$2
 634.      nr www-htmlimage-gap (\\$2 * 100 / 240)
 635.      shift 2
 636.      continue
 637.    \}
 638.    break
 639.  \}
 640.
 641.  nr www-width 1i
 642.  nr www-height 1i
 643.  ds www-size-specs "width=\\n[www-width] height=\\n[www-height]\"
 644.  ie !'\\$2'' \{\
 645.    nr www-is-absolute 0
 646.    nr www-absolute 0
 647.    ds www-percentage none\"
 648.    www-handle-percent \\$2 www-is-absolute www-absolute www-percentage
 649.    ie !\\n[www-is-absolute] \{\
 650.      \" percentage of linelength requested
 651.      nr www-width (\\n[www-absolute] * \\n[.l] / 100)
 652.      if \\n[www-html] \
 653.        nr www-width (\\n[www-width] * 100 / 240)
 654.      ds www-size-specs "width=\\*[www-percentage]\"
 655.    \}
 656.    el \{\
 657.      nr www-width \\n[www-absolute]
 658.      if \\n[www-html] \
 659.        nr www-width (\\n[www-width] * 100 / 240)
 660.      ds www-size-specs "width=\\n[www-width]\"
 661.    \}
 662.
 663.    nr www-height \\n[www-width]
 664.    ie !'\\$3'' \{\
 665.      nr www-is-absolute 0
 666.      nr www-absolute 0
 667.      ds www-percentage none\"
 668.      www-handle-percent \\$3 www-is-absolute www-absolute www-percentage
 669.      ie !\\n[www-is-absolute] \{\
 670.        \" percentage of pagelength requested
 671.        nr www-height (\\n[www-absolute] * \\n[.p] / 100)
 672.        if \\n[www-html] \
 673.           nr www-height (\\n[www-height] * 100 / 240)
 674.        ds www-size-specs "\\*[www-size-specs] height=\\*[www-percentage]\"
 675.      \}
 676.      el \{\
 677.        nr www-height \\n[www-absolute]
 678.        if \\n[www-html] \
 679.           nr www-height (\\n[www-height] * 100 / 240)
 680.        ds www-size-specs "\\*[www-size-specs] height=\\*[www-height]\"
 681.      \}
 682.    \}
 683.  \}
 684.  el \{\
 685.    \" height not specified; use width value
 686.    ie !\\n[www-is-absolute] \{\
 687.       \" percentage value
 688.       ds www-size-specs "\\*[www-size-specs] height=\\*[www-percentage]\"
 689.       nr www-height \\n[www-width]
 690.    \}
 691.    el \{\
 692.       ds www-size-specs "\\*[www-size-specs] height=\\*[www-width]\"
 693.       nr www-height \\n[www-width]
 694.    \}
 695.  \}
 696.
 697.  ie \\n[www-html] \{\
 698.    ie !\\n[www-image-just] \
 699.      HTML <img src="\\$1" alt="Image \\$1" hspace=\\n[www-htmlimage-gap] \
 700             align=right \\*[www-size-specs]>
 701.    el \
 702.      HTML <img src="\\$1" alt="Image \\$1" hspace=\\n[www-htmlimage-gap] \
 703             align=left \\*[www-size-specs]>
 704.  \}
 705.  el \{\
 706.    tm www-width is \\n[www-width]
 707.    tm www-height is \\n[www-height]
 708.    if !r ps4html \{\
 709.      www-make-unique-name
 710.      sy pngtopnm \\$1 | pnmcrop -white | @PNMTOPS_NOSETPAGE@ -noturn > \\*[www-unique-name].eps
 711.      ie !\\n[www-image-just] \{\
 712.        \" we must now disable a possible left image trap
 713.        sp -1
 714.        if (\\n[www-left-ll-trap] > 0) \
 715.          wh \\n[www-left-ll-trap]u
 716.        if (\\n[www-left-po-trap] > 0) \
 717.          wh \\n[www-left-po-trap]u
 718.        PSPIC -R \\*[www-unique-name].eps \\n[www-width]u \\n[www-height]u
 719.        sp -\\n[ps-desht]u
 720.        nr www-right-indent \\n[ps-deswid]u
 721.        \" we want to have some space between text and image,
 722.        \" so the line length must be shorter
 723.        ll -(\\n[www-right-indent]u + \\n[www-image-gap]u)
 724.        mk www-right-ll-trap
 725.        nr www-right-ll-trap +(\\n[ps-desht]u - 1v)
 726.        wh \\n[www-right-ll-trap]u www-finish-right-ll
 727.        \" now restore possible left trap
 728.        if (\\n[www-left-ll-trap] > 0) \
 729.          wh \\n[www-left-ll-trap]u www-finish-left-ll
 730.        if (\\n[www-left-po-trap] > 0) \
 731.          wh \\n[www-left-po-trap]u
 732.      \}
 733.      el \{\
 734.        \" we must now disable a possible right image trap
 735.        if (\\n[www-right-ll-trap] > 0) \
 736.          wh \\n[www-right-ll-trap]u
 737.        PSPIC -L \\*[www-unique-name].eps \\n[www-width]u \\n[www-height]u
 738.        sp -\\n[ps-desht]u
 739.        nr www-left-indent \\n[ps-deswid]u
 740.        \" increase offset by gap
 741.        po +(\\n[www-left-indent]u + \\n[www-image-gap]u)
 742.        \" decrease line length by gap
 743.        ll -(\\n[www-left-indent]u + \\n[www-image-gap]u)
 744.        mk www-left-ll-trap
 745.        nr www-left-ll-trap +(\\n[ps-desht]u - 1v)
 746.        wh \\n[www-left-ll-trap]u www-finish-left-ll
 747.        \" now restore possible right trap
 748.        if (\\n[www-right-ll-trap] > 0) \
 749.          wh \\n[www-right-ll-trap]u www-finish-right-ll
 750.      \}
 751.    \}
 752.  \}
 753..
 754.\" --------------------------------------------------------------------
 755.\" HnS n
 756.\"
 757.\"   Begin heading.  Heading level is N.
 758.\"
 759.\" HnE
 760.\"
 761.\"   End heading.
 762.\"
 763.\" If your heading contains URL, FTP, MTO macros you might wish to
 764.\" disable automatic links to headings.  This can be done via `-P-l'
 765.\" from the command line or by using a cakk to `.HX 0'.
 766.\"
 767.nr www-heading-no -1
 768.
 769.de HnS
 770.  ie '\\$1'' \
 771.    nr www-heading-no 1
 772.  el \
 773.    nr www-heading-no \\$1
 774.  DEVTAG-NH \\n[www-heading-no]
 775..
 776.
 777.de HnE
 778.  if (\\n[www-heading-no] == -1) \
 779.    www-error "HnE found without a corresponding HnS"
 780.  DEVTAG-EO-H
 781..
 782.\" --------------------------------------------------------------------
 783.\" LK
 784.\"
 785.\"   Emit the automatically collected links derived from
 786.\"   section/numbered headings at this position.
 787.\"
 788.de LK
 789.  DEVTAG ".links"
 790..
 791.\" --------------------------------------------------------------------
 792.\" HR
 793.\"
 794.\"   Produce a horizontal line.
 795.\"
 796.de HR
 797.  HTML</p> "<hr>"
 798..
 799.\" --------------------------------------------------------------------
 800.\" NHR
 801.\"
 802.\"  Suppresses the generation of the top and bottom rules which grohtml
 803.\"  emits by default.
 804.\"
 805.de NHR
 806.  DEVTAG ".no-auto-rule"
 807..
 808.\"
 809.\" www-end-nowhere - end of input trap called to finish diversion.
 810.\"
 811.de www-end-nowhere
 812.  if !\\n[www-html] \
 813.    di
 814.  DEVTAG-EO-TL
 815..
 816.\" --------------------------------------------------------------------
 817.\" HTL
 818.\"
 819.\"   Generate an HTML title only.  This differs from the -ms .TL macro
 820.\"   which generates both an HTML title and an H1 heading.
 821.\"
 822.\"   This is useful when an author wishes to use a HTML title as search
 823.\"   engine fodder but a graphic title in the document.
 824.\"
 825.\"   The macro terminates when a space or break is seen (.sp, .br).
 826.\"
 827.de HTL
 828.  DEVTAG ".html-tl"
 829.  if !\\n[www-html] \
 830.    di www-nowhere
 831.  it 2 www-end-nowhere
 832..
 833.
 834.\" --------------------------------------------------------------------
 835.\" auxiliary definitions for lists
 836.\"
 837.ds www-ul-level1 \[bu]\ \ \"
 838.ds www-ul-level2 \[sq]\ \ \"
 839.ds www-ul-level3 \[ci]\ \ \"
 840.nr www-ul-level 0
 841.
 842.ds www-ol-level1 decimal\"
 843.ds www-ol-level2 lower-alpha\"
 844.ds www-ol-level3 lower-roman\"
 845.ds www-ol-tmp 00\ \ \"
 846.nr www-ol-ctr1 0 1
 847.nr www-ol-ctr2 0 1
 848.nr www-ol-ctr3 0 1
 849.af www-ol-ctr2 a
 850.af www-ol-ctr3 i
 851.nr www-ol-level 0
 852.
 853.nr www-dl-level 0
 854.nr www-dl-shift 5n
 855.
 856.\"
 857.\" allow nested lists
 858.\"
 859.nr www-depth 0
 860.nr www-li-indent \n[.i]
 861.ds www-level0 nop\"
 862.ds www-level1
 863.ds www-level2
 864.ds www-level3
 865.ds www-level4
 866.ds www-level5
 867.ds www-level6
 868.ds www-level7
 869.ds www-level8
 870.ds www-level9
 871.
 872.\" which macro to use for LI
 873.de www-push-li
 874.  nr www-depth +1
 875.  ds www-level\\n[www-depth] \\$1\"
 876.  als LI \\$1
 877..
 878.
 879.de www-pop-li
 880.  nr www-depth -1
 881.  als LI \\*[www-level\\n[www-depth]]
 882..
 883.
 884.\"
 885.\" Auxiliary macro for ULS.
 886.\"
 887.de www-push-ul-level
 888.  nr www-ul-level +1
 889.  if (\\n[www-ul-level] > 3) \
 890.    www-error "ULS: too many levels of indentation (\\n[www-ul-level])"
 891..
 892.\"
 893.\" Auxiliary macro for ULE.
 894.\"
 895.de www-pop-ul-level
 896.  if !\\n[www-ul-level] \
 897.    www-error "ULE: trying to terminate a list which does not exist"
 898.  nr www-ul-level -1
 899..
 900.
 901.\"
 902.\" Auxiliary macro for OLS.
 903.\"
 904.de www-push-ol-level
 905.  nr www-ol-level +1
 906.  if (\\n[www-ol-level] > 3) \
 907.    www-error "OLS: too many levels of indentation (\\n[www-ol-level])"
 908..
 909.\"
 910.\" Auxiliary macro for OLE.
 911.\"
 912.de www-pop-ol-level
 913.  if !\\n[www-ol-level] \
 914.    www-error "OLE: trying to terminate a list which does not exist"
 915.  nr www-ol-level -1
 916..
 917.
 918.\" --------------------------------------------------------------------
 919.\" ULS
 920.\"
 921.\"   Start an unordered list.
 922.\"
 923.de ULS
 924.  www-push-li www-li-ul
 925.  www-push-ul-level
 926.  ie \\n[www-html] \
 927.    HTML</p> "<ul>"
 928.  el \{\
 929.    nr www-li-indent +\w'\\*[www-ul-level\\n[www-ul-level]]'u
 930.  \}
 931..
 932.\" --------------------------------------------------------------------
 933.\" ULE
 934.\"
 935.\"   End an unordered list.
 936.\"
 937.de ULE
 938.  ie \\n[www-html] \
 939.    HTML "</ul>"
 940.  el \{\
 941.    nr www-li-indent -\w'\\*[www-ul-level\\n[www-ul-level]]'u
 942.    in \\n[www-li-indent]u
 943.  \}
 944.  www-pop-ul-level
 945.  www-pop-li
 946..
 947.\" --------------------------------------------------------------------
 948.\" OLS
 949.\"
 950.\"   Start an ordered list.
 951.\"
 952.de OLS
 953.  www-push-li www-li-ol
 954.  www-push-ol-level
 955.  ie \\n[www-html] \
 956.    HTML</p> "<ol style='list-style-type: \\*[www-ol-level\\n[www-ol-level]]'>"
 957.  el \
 958.    nr www-li-indent +\w'\\*[www-ol-tmp]'u
 959..
 960.\" --------------------------------------------------------------------
 961.\" OLE
 962.\"
 963.\"   End an ordered list.
 964.\"
 965.de OLE
 966.  ie \\n[www-html] \
 967.    HTML "</ol>"
 968.  el \{\
 969.    nr www-li-indent -\w'\\*[www-ol-tmp]'u
 970.    in \\n[www-li-indent]u
 971.    nr www-ol-ctr\\n[www-ol-level] 0 1
 972.  \}
 973.  www-pop-ol-level
 974.  www-pop-li
 975..
 976.\" --------------------------------------------------------------------
 977.\"
 978.\" DLS
 979.\"   Start a definition list.
 980.\"
 981.de DLS
 982.  www-push-li www-li-dl
 983.  nr www-dl-level +1
 984.  ie \\n[www-html] \
 985.    HTML</p> "<dl>"
 986.  el \{\
 987.    nr www-li-indent +\\n[www-dl-shift]u
 988.    in \\n[www-li-indent]u
 989.  \}
 990..
 991.\" --------------------------------------------------------------------
 992.\"
 993.\" DLE
 994.\"   End a definition list.
 995.\"
 996.de DLE
 997.  ie \\n[www-html] \
 998.    HTML "</dl>"
 999.  el \{\
1000.    nr www-li-indent -\\n[www-dl-shift]u
1001.    in \\n[www-li-indent]u
1002.  \}
1003.  nr www-dl-level -1
1004.  www-pop-li
1005..
1006.\" --------------------------------------------------------------------
1007.\" LI
1008.\"
1009.\"   Insert a list item.
1010.\"
1011.\" ********
1012.\" www-li-ul - bulleted list item
1013.\"
1014.de www-li-ul
1015.  ie \\n[www-html] \
1016.    HTML-NS "<li>"
1017.  el \{\
1018.    www:paraspace
1019.    in \\n[www-li-indent]u
1020.    ti -\w'\\*[www-ul-level\\n[www-ul-level]]'u
1021.    nop \\*[www-ul-level\\n[www-ul-level]]\c
1022.  \}
1023..
1024.\" ********
1025.\" www-li-ol - numbered list item
1026.\"
1027.de www-li-ol
1028.  ie \\n[www-html] \
1029.    HTML-NS "<li>"
1030.  el \{\
1031.    www:paraspace
1032.    in \\n[www-li-indent]u
1033.    ti -\w'\\n[www-ol-ctr\\n[www-ol-level]]\ \ 'u
1034.    nop \\n+[www-ol-ctr\\n[www-ol-level]]\ \ \c
1035.  \}
1036..
1037.\" ********
1038.\" www-li-dl - definition list item
1039.\"
1040.de www-li-dl
1041.  ie \\n[www-html] \{\
1042.    HTML "<dt>\\$1</dt>"
1043.    HTML-NS "<dd>"
1044.  \}
1045.  el \{\
1046.    www:paraspace
1047.    in \\n[www-li-indent]u
1048.    ti -\\n[www-dl-shift]u
1049.    nop \&\\$1
1050.    br
1051.  \}
1052..
1053.\" --------------------------------------------------------------------
1054.\" DC l text [color]
1055.\"
1056.\"   L is the letter to be dropped and enlarged.
1057.\"
1058.\"   TEXT is the following text whose height the first letter should not
1059.\"   exceed.
1060.\"
1061.\"   COLOR is the optional color of the dropped letter (default black).
1062.\"
1063.de DC
1064.  ds www-dropcolor black
1065.  if !'\\$3'' \
1066.    ds www-dropcolor \\$3
1067.  ie '\*(.T'html' \{\
1068.    www-make-unique-name
1069.    nr www-drop-width (100u * \\n[.v]u * 3u / \\n[.l]u)
1070.    MPIMG -L \\*[www-unique-name].png "\\n[www-drop-width]%"
1071.  \}
1072.  el \{\
1073.    ie r ps4html \{\
1074.      www-make-unique-name
1075.      \" To avoid interferences with another DC macro call which is located
1076.      \" very near to the current one, we draw the glyph on a separate page.
1077.      \" Otherwise it could theoretically happen that the dropped capital
1078.      \" glyphs overlap.
1079.      bp
1080.      ev www-DC
1081.      vs 320p
1082.      nop \O[5i\\*[www-unique-name].png]\O[1]
1083.      nop \m[\\*[www-dropcolor]]\s[160]\O[3]\\$1\O[4]
1084.      nop \O[2]\O[0]
1085.      br
1086.      ev
1087.      bp
1088.    \}
1089.    el \{\
1090.      ie n \
1091.        nop \\$1\c
1092.      el \{\
1093.        nr dummy \w'\\$1'u
1094.        nr dcht ((\\n[.v] + \\n[rst]) * \\n[.ps] / \\n[rst])
1095.        char \[dcap] \m[\\*[www-dropcolor]]\s'\\n[dcht]u'\\$1
1096.        nop \v'\\n[.v]u'\\[dcap]\v'-\\n[.v]u'\c
1097'        ti \w'\\[dcap]'u
1098.      \}
1099.    \}
1100.  \}
1101.  nop \\$2
1102..
1103.\" --------------------------------------------------------------------
1104.\" Setup around HTML-IMAGE and friends
1105.\"
1106.\" now set up TS, TE, EQ, EN default macros
1107.\"
1108.do if !d TS .do ds TS HTML-IMAGE
1109.do if !d TE .do ds TE HTML-IMAGE-END
1110.do if !d EQ .do ds EQ HTML-IMAGE
1111.do if !d EN .do ds EN HTML-IMAGE-END
1112.\"
1113.\" supplementary macros used by other macro sets
1114.\"
1115.\" here are some tags specially for -Tps or -Thtml when invoked by
1116.\" pre-html to generate png images from postscript.
1117.
1118.\" --------------------------------------------------------------------
1119.\" HTML-DO-IMAGE - tells troff to issue an image marker which can be
1120.\"                 read back by pre-html
1121.\"
1122.de HTML-DO-IMAGE
1123.  if r ps4html \
1124.    nop \O[5\\$2\\$1.png]\O[1]\O[3]
1125.  if \\n[www-html] \
1126.    nop \O[5\\$2\\$1.png]\O[0]\O[3]
1127..
1128.\" --------------------------------------------------------------------
1129.\" HTML-IMAGE-END - terminates an image for html
1130.\"
1131.de HTML-IMAGE-END
1132.  if r ps4html \
1133.    nop \O[4]\O[2]\O[0]
1134.  if \\n[www-html] \
1135.    nop \O[4]\O[2]\O[1]
1136..
1137.
1138.nr www-png-no 0
1139.
1140.\" --------------------------------------------------------------------
1141.\" www-make-unique-name - generates another unique name in string
1142.\"                        `www-unique-name'
1143.\"
1144.de www-make-unique-name
1145.  nr www-png-no +1
1146.  ds www-unique-name \\*[www-image-template]\\n[www-png-no]
1147..
1148.\" --------------------------------------------------------------------
1149.\" HTML-IMAGE and friends tell grohtml that this region of text needs
1150.\"            to be rendered as an image.
1151.\"
1152.de HTML-IMAGE
1153.  \" generates a centered image
1154.  www-make-unique-name
1155.  HTML-DO-IMAGE \\*[www-unique-name] c
1156..
1157.
1158.de HTML-IMAGE-RIGHT
1159.  www-make-unique-name
1160.  HTML-DO-IMAGE \\*[www-unique-name] r
1161..
1162.
1163.de HTML-IMAGE-LEFT
1164.  www-make-unique-name
1165.  HTML-DO-IMAGE \\*[www-unique-name] l
1166..
1167.
1168.de HTML-IMAGE-INLINE
1169.  www-make-unique-name
1170.  HTML-DO-IMAGE \\*[www-unique-name] i
1171..
1172.
1173.\" --------------------------------------------------------------------
1174.\" JOBNAME
1175.\"
1176.\"   Generate multiple output files containing the html.
1177.\"   A file is split whenever a .SH or .NH 1 is encountered.
1178.\"   The argument to JOBNAME is the file stem for future output files.
1179.\"
1180.de JOBNAME
1181.  DEVTAG .job-name \\$1
1182..
1183.\" --------------------------------------------------------------------
1184.\" HEAD
1185.\"
1186.\"   Adds information to the <head> </head> section of the html
1187.\"   document
1188.\" --------------------------------------------------------------------
1189.de HEAD
1190.  DEVTAG .head "\\$*"
1191..
1192.\" --------------------------------------------------------------------
1193.\" Final Setup
1194.\" --------------------------------------------------------------------
1195.
1196.if \n[www-html] \{\
1197.   nh
1198.   nr HY 0
1199.\}
1200.
1201.\"
1202.\" start of some code
1203.\"
1204.
1205.de CDS
1206.ft C
1207.nf
1208..
1209.\"
1210.\" end of some code
1211.\"
1212.
1213.de CDE
1214.fi
1215.ft P
1216..
1217.
1218.if r ps4html .nop \O[0]
1219.cp \n(_C
1220.
1221.\" now set
1222.
1223.\" --------------------------------------------------------------------
1224.\" Emacs settings
1225.\" --------------------------------------------------------------------
1226.
1227.\" Local Variables:
1228.\" mode: nroff
1229.\" End:
1230.\" EOF