summaryrefslogtreecommitdiffstats
path: root/contrib/groff/tmac/www.tmac
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/groff/tmac/www.tmac')
-rw-r--r--contrib/groff/tmac/www.tmac373
1 files changed, 326 insertions, 47 deletions
diff --git a/contrib/groff/tmac/www.tmac b/contrib/groff/tmac/www.tmac
index 0db647e..621da7e 100644
--- a/contrib/groff/tmac/www.tmac
+++ b/contrib/groff/tmac/www.tmac
@@ -1,8 +1,47 @@
-.\" www.tmac
-.\"
-.\" A simple set of macros to provide HTML documents with basic
-.\" www functionality. It should work with any macro set.
-.\"
+.ig
+www.tmac - macro package for adding HTML elements to roff documents.
+
+File position: <groff_source_top>/tmac/www.tmac
+Installed position: groff's main macro directory.
+
+------------------------------------------------------------------------
+ Legalize
+------------------------------------------------------------------------
+
+This file is part of groff, the GNU roff type-setting system.
+
+Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+written by Gaius Mulley <gaius@glam.ac.uk>, with additions by
+Werner Lemberg <wl@gnu.org> and Bernd Warken <bwarken@mayn.de>.
+
+groff is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+groff is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with groff; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+
+
+------------------------------------------------------------------------
+ Description
+------------------------------------------------------------------------
+
+A simple set of macros to provide HTML documents with basic
+www functionality. It should work with any macro set.
+..
+.
+.\" --------------------------------------------------------------------
+.\" Setup
+.\" --------------------------------------------------------------------
+.
.nr _C \n(.C
.cp 0
.
@@ -10,8 +49,6 @@
.if '\*[.T]'html' .nr www-html 1
.
.\" set up www-image-template
-.\" (cannot do this in html.tmac as the image device must
-.\" also know about this string)
.
.if !d www-image-template \
. ds www-image-template
@@ -27,9 +64,187 @@
. .
.\}
.
+.
+.\" --------------------------------------------------------------------
+.\" Test for `.substring'; result in register `www.substring_ok'.
+.\" The automated break points in .URL addresses are only added if
+.\" this register is non-zero.
+.\"
+.nr www:substring_ok 0
+.de www:@test_substring
+. if !d substring \
+. return
+. ds \\$0:s abcdefg\"
+. substring \\$0:s 1 1
+. if !'\\*[\\$0:s]'b' \{\
+. rm \\$0:s
+. return
+. \}
+. ds \\$0:s abcdefg\"
+. substring \\$0:s 0 0
+. if !'\\*[\\$0:s]'a' \{\
+. rm \\$0:s
+. return
+. \}
+. ds \\$0:s abcdefg\"
+. substring \\$0:s 1 -1
+. if !'\\*[\\$0:s]'bcdefg' \{\
+. rm \\$0:s
+. return
+. \}
+. nr www:substring_ok 1
+. rm \\$0:s
+..
+.www:@test_substring
+.rm www:@test_substring
+.
+.
+.\" --------------------------------------------------------------------
+.\" Local Macros
+.\" --------------------------------------------------------------------
+.
+.\" --------------------------------------------------------------------
+.\" www:error (<test>...)
+.\"
+.\" Print error message
+.\"
.de www-error
. tm \\n[.F]:\\n[.c]: macro error: \\$*
..
+.als www:error www-error
+.
+.\" --------------------------------------------------------------------
+.\" www:lenstr (<register_name> <string_name>)
+.\"
+.\" Store length of string named <string_name> into register named
+.\" <register_name>.
+.\"
+.de www:lenstr
+. if !(\\n[.$] == 2) \{\
+. tm .\\$0 expects 2 arguments.
+. ab
+. \}
+. length \\$0:n x\\*[\\$2]
+. nr \\$1 (\\n[\\$0:n]-1)
+. rr \\$0:n
+..
+.\" --------------------------------------------------------------------
+.\" www:splitstr (<name>)
+.\"
+.\" Add a space character between any two adjacent characters in string
+.\" <name> and restore result into the string variable <name>; space
+.\" characters are first replaced by the word `space'.
+.\"
+.de www:splitstr
+. if !(\\n[.$] == 1) \
+. www:error .\\$0 expects 1 argument.
+. if '\\*[\\$1]'' \
+. return
+. ds \\$0:r "\\*[\\$1]\""
+. ds \\$0:s\"
+. while 1 \{\
+. ds \\$0:c "\\*[\\$0:r]\""
+. substring \\$0:c 0 0\"
+. ie '\\*[\\$0:c]' ' \
+. as \\$0:s " space\""
+. el \
+. as \\$0:s " \\*[\\$0:c]\""
+. www:lenstr \\$0:n \\$0:r
+. if (\\n[\\$0:n] <= 1) \{\
+. break
+. \}
+. substring \\$0:r 1 -1\"
+. \}
+. if !'\\*[\\$0:s]'' \
+. substring \\$0:s 1 -1
+. ds \\$1 \\*[\\$0:s]
+. rm \\$0:c
+. rr \\$0:n
+. rm \\$0:r
+. rm \\$0:s
+..
+.\" --------------------------------------------------------------------
+.\" www:url_breaks (<string_name>)
+.\"
+.\" Add `\:' (possible break point) within URL strings after `/'.
+.\"
+.\" Smart about multiple `/', existing `\:', and space characters;
+.\" does not set a break point if less than 5 characters would go to
+.\" the next line.
+.\"
+.de www:url_breaks
+. if !(\\n[.$] == 1) \
+. www:error .\\$0 expects 1 argument.
+. if !\n[www:substring_ok] \
+. return
+. ds \\$0:s "\\*[\\$1]\""
+. www:splitstr \\$0:s
+. www:url_breaks_splitted \\$0:s \\*[\\$0:s]
+. ds \\$1 "\\*[\\$0:s]\""
+. rm \\$0:s
+..
+.\" --------------------------------------------------------------------
+.\" www:url_breaks_splitted (<result> <char> [<char>...])
+.\"
+.\" Add `\:' within URL strings, but arguments are a splitted string.
+.\"
+.\" Arguments: >=2: <result> <char> [<char>...]
+.\"
+.de www:url_breaks_splitted
+. nr \\$0:min 5 \" minimal number of characters for next line
+. if (\\n[.$] < 2) \
+. www:error .\\$0 expects at least 2 arguments.
+. ds \\$0:res \\$1\"
+. shift
+. ds \\$0:s\"
+. nr \\$0:done 0
+. while !\\n[\\$0:done] \{\
+. if (\\n[.$] <= 0) \{\
+. nr \\$0:done 1
+. break
+. \}
+. if '\\$1'space' \{\
+. as \\$0:s " \""
+. shift
+. continue
+. \}
+. if (\\n[.$] < \\n[\\$0:min]) \{\
+. as \\$0:s "\\$1\""
+. shift
+. continue
+. \}
+. if !'\\$1'/' \{\
+. as \\$0:s "\\$1\""
+. shift
+. continue
+. \}
+. \" we are at a `/' character
+. while '\\$1'/' \{\
+. as \\$0:s /\"
+. if (\\n[.$] == 0) \{\
+. nr \\$0:done 1
+. break
+. \}
+. shift
+. \}
+. if \\n[\\$0:done] \
+. break
+. if (\\n[.$] < \\n[\\$0:min]) \
+. continue
+. if '\\$1'\:' \
+. shift
+. as \\$0:s \:\"
+. \}
+. ds \\*[\\$0:res] \\*[\\$0:s]\"
+. rm \\$0:res
+. rm \\$0:s
+..
+.\" --------------------------------------------------------------------
+.\" User Interface
+.\" --------------------------------------------------------------------
+.
+.\" --------------------------------------------------------------------
+.\" HTML (<address> <description> [<punctuation>])
.\"
.\" the main auxiliary macro for the HTML interface
.\"
@@ -47,47 +262,61 @@
. if \\n[www-html] \
. nop \X^html:\\$*^\c
..
-.\"
+.\" --------------------------------------------------------------------
.\" HX n
.\"
.\" Automatic heading level cut off.
.\"
.\" N is the depth limit of automatically linked headings. So a depth
-.\" of 2 would cause grohtml to generate a list of links for `.NH 1' and
-.\" `.NH 2' but not for `.NH 3'.
+.\" of 2 would cause grohtml to generate a list of links for `.NH 1'
+.\" and `.NH 2' but not for `.NH 3'.
.\"
.de HX
. if \\n[www-html] \
. nop \X^index:\\$*^
..
-.\"
+.\" --------------------------------------------------------------------
.\" BCL foreground background active not-visited visited
.\"
.de BCL
. HTML <body text=\\$1 bgcolor=\\$2 link=\\$3 alink=\\$4 vlink=\\$5>
..
-.\"
+.\" --------------------------------------------------------------------
.\" BGIMG imagefile
.\"
.de BGIMG
. HTML <body background=\\$1>
..
-.\"
-.\" URL url description [after]
+.\" --------------------------------------------------------------------
+.\" URL url [description] [after]
+.\" if description is absent then the url becomes the anchor text
.\"
.de URL
-. ie \\n[www-html] \
-. HTML <a href="\\$1">\\$2</a>\\$3
-. el \
-. nop \m[blue]\\$2\m[] \%\[la]\f[C]\\$1\f[]\[ra]\\$3
+. ds \\$0:adr \\$1\"
+. www:url_breaks \\$0:adr
+. ie \\n[www-html] \{\
+. ie '\\$2'' \
+. HTML <a href="\\$1">\\$1</a>\\$3
+. el \
+. HTML <a href="\\$1">\\$2</a>\\$3
+. \}
+. el \{\
+. if !r ps4html .ad l
+. ie '\\$2'' \
+. nop \%\[la]\m[blue]\f[C]\\*[\\$0:adr]\f[]\m[]\[ra]\\$3
+. el \
+. nop \m[blue]\\$2\m[] \%\[la]\f[C]\\*[\\$0:adr]\f[]\[ra]\\$3
+. if !r ps4html .ad
+. \}
+. rm \\$0:adr
..
-.\"
+.\" --------------------------------------------------------------------
.\" FTP url description [after]
.\"
-.\" Same as UTL.
+.\" Same as URL.
.\"
.als FTP URL
-.\"
+.\" --------------------------------------------------------------------
.\" MTO address description [after]
.\"
.\" ADDRESS is the email address (without the `mailto:' prefix).
@@ -117,7 +346,7 @@
. nop \m[blue]\\$2\m[] \%\[la]\f[C]\\$1\f[]\[ra]\\$3
. \}
..
-.\"
+.\" --------------------------------------------------------------------
.\" TAG name
.\"
.\" Generate an html name NAME.
@@ -125,7 +354,7 @@
.de TAG
. HTML <a name="\\$1"></a>
..
-.\"
+.\" --------------------------------------------------------------------
.\" IMG [-R|-L|-C] filename [width] [height]
.\"
.\" Include an image of any type (will only work for -Thtml).
@@ -155,7 +384,7 @@
. el \
. nop \[la]\f[C]\\$1\f[]\[ra]
..
-.\"
+.\" --------------------------------------------------------------------
.\" HTML-TAG
.\"
.\" Emit a tag for grohtml. This is an internal macro.
@@ -167,7 +396,7 @@
. nop \X^html-tag:\\$*^
. \}
..
-.\"
+.\" --------------------------------------------------------------------
.\" HTML-TAG-NS
.\"
.\" Emit a tag for grohtml (without a space). This is an internal macro.
@@ -176,7 +405,7 @@
. if \\n[www-html] \
. nop \X^html-tag:\\$*^\c
..
-.\"
+.\" --------------------------------------------------------------------
.\" PIMG [-R|-L|-C] filename [width] [height]
.\"
.\" Include a png image. It will work for -Tps and -Thtml.
@@ -219,7 +448,7 @@
. el \{\
. if !r ps4html \{\
. www-make-unique-name
-. sy pngtopnm \\$2 | pnmcrop -white | pnmtops -noturn > \\*[www-unique-name].eps
+. sy pngtopnm \\$2 | pnmcrop -white | @PNMTOPS_NOSETPAGE@ -noturn > \\*[www-unique-name].eps
. ie '\\$1'-C' \
. PSPIC \\*[www-unique-name].eps \\$3 \\$4
. el \
@@ -228,6 +457,9 @@
. \}
..
.
+.\" --------------------------------------------------------------------
+.\" auxiliary definitions for MPIMG
+.\"
.nr www-left-ll-trap 0
.nr www-left-po-trap 0
.nr www-right-ll-trap 0
@@ -274,7 +506,7 @@
. wh \\n[www-left-ll-trap]u
. nr www-left-ll-trap 0
..
-.\"
+.\" --------------------------------------------------------------------
.\" MPIMG [-R|-L] filename [width] [height]
.\"
.\" Include a png image and wrap text around it. It will work for
@@ -303,7 +535,7 @@
. el \{\
. if !r ps4html \{\
. www-make-unique-name
-. sy pngtopnm \\$2 | pnmcrop -white | pnmtops -noturn > \\*[www-unique-name].eps
+. sy pngtopnm \\$2 | pnmcrop -white | @PNMTOPS_NOSETPAGE@ -noturn > \\*[www-unique-name].eps
. ie '\\$1'-R' \{\
. \" we must now disable a possible left image trap
. sp -1
@@ -343,7 +575,7 @@
. \}
. \}
..
-.\"
+.\" --------------------------------------------------------------------
.\" HnS n
.\"
.\" Begin heading. Heading level is N.
@@ -371,7 +603,7 @@
. www-error "HnE found without a corresponding HnS"
. br
..
-.\"
+.\" --------------------------------------------------------------------
.\" LK
.\"
.\" Emit the automatically collected links derived from
@@ -380,7 +612,7 @@
.de LK
. HTML-TAG ".links"
..
-.\"
+.\" --------------------------------------------------------------------
.\" HR
.\"
.\" Produce a horizontal line
@@ -393,7 +625,7 @@
. el \
. sp
..
-.\"
+.\" --------------------------------------------------------------------
.\" NHR
.\"
.\" Suppresses the generation of the top and bottom rules which grohtml
@@ -408,7 +640,7 @@
.de www-end-nowhere
. di
..
-.\"
+.\" --------------------------------------------------------------------
.\" HTL
.\"
.\" Generate an HTML title only. This differs from the -ms .TL macro
@@ -427,6 +659,9 @@
. \}
..
.
+.\" --------------------------------------------------------------------
+.\" auxiliary definitions for ULS / ULE
+.\"
.ds www-level1 \[bu]\ \ \"
.ds www-level2 \[sq]\ \ \"
.ds www-level3 \[ci]\ \ \"
@@ -449,7 +684,7 @@
. www-error "trying to terminate a list which does not exist"
. nr www-level -1
..
-.\"
+.\" --------------------------------------------------------------------
.\" ULS
.\"
.\" Start an unordered list.
@@ -464,7 +699,7 @@
. nr www-depth +\w'\\*[www-level\\n[www-level]]'u
. \}
..
-.\"
+.\" --------------------------------------------------------------------
.\" ULE
.\"
.\" End an unordered list.
@@ -474,11 +709,11 @@
. HTML "</ul>"
. el \{\
. nr www-depth -\w'\\*[www-level\\n[www-level]]'u
-. in \\n[www-depth]
+. in \\n[www-depth]u
. \}
. www-pop-level
..
-.\"
+.\" --------------------------------------------------------------------
.\" LI
.\"
.\" Insert a list item.
@@ -492,7 +727,7 @@
. nop \\*[www-level\\n[www-level]]\c
. \}
..
-.\"
+.\" --------------------------------------------------------------------
.\" DC l text [color]
.\"
.\" L is the letter to be dropped and enlarged.
@@ -513,9 +748,19 @@
. el \{\
. ie r ps4html \{\
. www-make-unique-name
+. \" To avoid interferences with another DC macro call which is located
+. \" very near to the current one, we draw the glyph on a separate page.
+. \" Otherwise it could theoretically happen that the dropped capital
+. \" glyphs overlap.
+. bp
+. ev www-DC
+. vs 80p
. nop \O[5i\\*[www-unique-name].png]\O[1]
-. nop \m[\\*[www-dropcolor]]\s[40]\O[3]\\$1\O[4]\s0\m[]
-. nop \O[2]\O[1]
+. nop \m[\\*[www-dropcolor]]\s[40]\O[3]\\$1\O[4]
+. nop \O[2]\O[0]
+. br
+. ev
+. bp
. \}
. el \{\
. nr dummy \w'\\$1'u
@@ -527,6 +772,8 @@
. \}
. nop \\$2
..
+.\" --------------------------------------------------------------------
+.\" Setup around HTML-IMAGE and friends
.\"
.\" now set up TS, TE, EQ, EN default macros
.\"
@@ -537,9 +784,10 @@
.\"
.\" supplementary macros used by other macro sets
.\"
-.\" here are some tags specially for -Tps or -Thtml when invoked by pre-html
-.\" to generate png images from postscript.
-.\"
+.\" here are some tags specially for -Tps or -Thtml when invoked by
+.\" pre-html to generate png images from postscript.
+.
+.\" --------------------------------------------------------------------
.\" HTML-DO-IMAGE - tells troff to issue an image marker which can be
.\" read back by pre-html
.\"
@@ -549,7 +797,7 @@
. if \\n[www-html] \
. nop \O[5\\$2\\$1.png]\O[0]\O[3]
..
-.\"
+.\" --------------------------------------------------------------------
.\" HTML-IMAGE-END - terminates an image for html
.\"
.de HTML-IMAGE-END
@@ -561,7 +809,7 @@
.
.nr www-png-no 0
.
-.\"
+.\" --------------------------------------------------------------------
.\" www-make-unique-name - generates another unique name in string
.\" `www-unique-name'
.\"
@@ -569,7 +817,7 @@
. nr www-png-no +1
. ds www-unique-name \\*[www-image-template]\\n[www-png-no]
..
-.\"
+.\" --------------------------------------------------------------------
.\" HTML-IMAGE and friends tell grohtml that this region of text needs
.\" to be rendered as an image.
.\"
@@ -594,11 +842,42 @@
. HTML-DO-IMAGE \\*[www-unique-name] i
..
.
+.\" --------------------------------------------------------------------
+.\" Final Setup
+.\" --------------------------------------------------------------------
+.
.if \n[www-html] \{\
. nh
. nr HY 0
.\}
+.
+.\"
+.\" start of some code
+.\"
+.
+.de CDS
+.ft C
+.nf
+..
+.\"
+.\" end of some code
+.\"
+.
+.de CDE
+.fi
+.ft P
+..
+.
.if r ps4html .nop \O[0]
.cp \n(_C
.
+.\" now set
+.
+.\" --------------------------------------------------------------------
+.\" Emacs settings
+.\" --------------------------------------------------------------------
+.
+.\" Local Variables:
+.\" mode: nroff
+.\" End:
.\" EOF
OpenPOWER on IntegriCloud