* src/libs/libdriver/input.cc [USE_ENV_STACK]: New macro to comment
[s-roff.git] / tmac / www.tmac
blobc3f1aac2cdd7e648d44ad8afd08a82a2138ce58f
1 .\" www.tmac
2 .\"
3 .\" A simple set of macros to provide HTML documents with basic
4 .\" www functionality.  It should work with any macro set.
5 .\"
6 .nr _C \n(.C
7 .cp 0
9 .nr www-html 0
10 .if '\*[.T]'html' .nr www-html 1
12 .if r ps4html \{\
13 .  \" remove the title command when we are generating images for html
14 .  \" (stops a title accidentally appearing inside an image)
15 .  tl ````
16 .  rm tl
17 .  de tl
18 .  .
19 .\}
21 .\"
22 .\" the main auxiliary macro for the HTML interface
23 .\"
24 .de HTML
25 .  if \\n[www-html] \{\
26 .    \" the following line makes the vertical mode leave, so to say
27 .    nop \&
28 .    nop \X^html:\\$*^
29 .  \}
31 .\"
32 .\"
33 .\"
34 .de HTMLINDEX
35 .  if \\n[www-html] \
36 .    nop \X^index:\\$*^
38 .\"
39 .\"  BODYCOLOR - $1 is foreground color
40 .\"              $2 is background color
41 .\"              $3 is the color of an active hypertext link
42 .\"              $4 is the color of a hypertext link not yet visited
43 .\"              $5 is the color of a visited hypertext link
44 .\"
45 .de BODYCOLOR
46 .  HTML <body text=\\$1 bgcolor=\\$2 link=\\$3 alink=\\$4 vlink=\\$5>
48 .\"
49 .\" BACKGROUND - $1 is the background image file
50 .\"
51 .de BACKGROUND
52 .  HTML <body background=\\$1>
54 .\"
55 .\"  URL - $1 is the classical underlined blue text
56 .\"        $2 is the url
57 .\"        $3 is optional stuff printed immediately after $3
58 .\"
59 .de URL
60 .  ie \\n[www-html] \
61 .    HTML <a href="\\$2">\\$1</a>\\$3
62 .  el \
63 .    nop \m[blue]\\$1\mP \%\[la]\fC\\$2\fP\[ra]\\$3
65 .\"
66 .\"  FTP - $1 is the classical underlined blue text
67 .\"        $2 is the ftp url
68 .\"        $3 is optional stuff printed immediately after $2
69 .\"
70 .de FTP
71 .  ie \\n[www-html] \
72 .    HTML <a href=\\$2>\\$1</a>\\$3
73 .  el \
74 .    nop \m[blue]\\$1\mP \%\[la]\fC\\$2\fP\[ra]\\$3
76 .\"
77 .\" MAILTO - generate html email reference
78 .\"          $1 is the email address (without the `mailto:' prefix)
79 .\"          $2 is the optional name
80 .\"          $3 is optional stuff printed immediately after $2 (resp. $1)
81 .\"
82 .\"          example:
83 .\"
84 .\"            Foobar has been written by
85 .\"            .MAILTO fred@foo.bar "Fredrick Bloggs" .
86 .\"
87 .de MAILTO
88 .\"
89 .\" force reset after a potential heading by performing some motion..
90 .\" how do we do this --fixme--
91 .\"  \h'\w' ''\h'-\w' '' doesn't work..
92 .  ie \\n[www-html] \{\
93 .    ie '\\$2'' \
94 .      HTML "<a href=mailto:\\$1>\\$1</a>\\$3"
95 .    el \
96 .      HTML "<a href=mailto:\\$1>\\$2</a>\\$3"
97 .  \}
98 .  el \{\
99 .    ie '\\$2'' \
100 .      nop \m[blue]\fC\\$1\fP\mP\\$3
101 .    el \
102 .      nop \m[blue]\\$2\mP \%\[la]\fC\\$1\fP\[ra]\\$3
103 .  \}
106 .\" TAG - generate an html name $1
108 .de TAG
109 .  HTML <a name="\\$1"></a>
112 .\" IMAGE - reference an image
113 .\"         $1 is the image file
114 .\"         $2 is the alignment r, l or c (centered by default)
115 .\"         $3 is the x width (default if absent is 400 pixels)
116 .\"         $4 is the y width (default if absent is the x value)
118 .de IMAGE
119 .  ie \\n[www-html] \{\
120 .    ie '\\$2'r' \
121 .      HTML-TAG ".right-image"
122 .    el \{\
123 .      ie '\\$2'l' \
124 .        HTML-TAG ".left-image"
125 .      el \
126 .        HTML-TAG ".centered-image"
127 .    \}
128 .    nr www-width 400
129 .    if !'\\$3'' \
130 .      nr www-width \\$3
131 .    nr www-height \\n[www-width]
132 .    if !'\\$4'' \
133 .      nr www-height \\$4
134 .    HTML <img src="\\$1" width=\\n[www-width] height=\\n[www-height]>
135 .  \}
136 .  el \{\
137 .    B1
138 .    nop \[la]\fC\\$1\fP\[ra]
139 .    B2
140 .  \}
143 .\" HTML-TAG - emit a tag for the grohtml
145 .de HTML-TAG
146 .  if \\n[www-html] \{\
147 .    \" the following line makes the vertical mode leave, so to say
148 .    nop \&
149 .    nop \X^html-tag:\\$*^
150 .  \}
153 .\" LINKS - emit the automatically collected links derived from
154 .\"         section/numbered headings at this position.
156 .de LINKS
157 .  HTML-TAG ".links"
160 .\" LINE - produce a horizontal line
162 .de LINE
163 .  ti 0
164 .  HTML <hr>
167 .\"  NO-AUTO-RULE - suppresses the generation of the top and bottom rules
168 .\"                 which grohtml emits by default.
170 .de NO-AUTO-RULE
171 .  HTML-TAG ".no-auto-rule"
174 .\"  www-end-nowhere - end of input trap called to finish diversion.
176 .de www-end-nowhere
177 .  di
180 .\"  HTML-TL - generate a HTML title only
181 .\"            which differs from the -ms .TL which generates
182 .\"            both a HTML title and a H1 heading.
183 .\"            This is useful when an author wishes to use a HTML title
184 .\"            as search engine fodder but use a graphic in the document.
186 .de HTML-TL
187 .  HTML-TAG ".html-tl"
188 .  if !\\n[www-html] \{\
189 .    di www-nowhere
190 .    it 2 www-end-nowhere
191 .  \}
194 .ds www-level1 \[bu]\ \ \"
195 .ds www-level2 \[sq]\ \ \"
196 .ds www-level3 \[ci]\ \ \"
197 .nr www-level 0
200 .\" auxiliary macro for UL-BEGIN
202 .de www-push-level
203 .  nr www-level +1
204 .  if (\\n[www-level] > 3) \
205 .    @error "too many levels of indentation (\\n[www-level])"
208 .\" auxiliary macro for UL-END
210 .de www-pop-level
211 .  if !\\n[www-level] \
212 .    @error "trying to terminate a list which does not exist"
213 .  nr www-level -1
214 .  HTML "</ul>"
217 .\" start an unordered list
219 .de UL-BEGIN
220 .  www-push-level
221 .  ie \\n[www-html] \
222 .    HTML "<ul>"
223 .  el \{\
224 .    br
225 .    in +\w'\\*[www-level\\n[www-level]]'
226 .  \}
229 .\" end an unordered list
231 .de UL-END
232 .  ie \\n[www-html] \
233 .    HTML "</ul>"
234 .  el \{\
235 .    br
236 .    in -\w'\\*[www-level\\n[www-level]]'
237 .  \}
238 .  www-pop-level
241 .\" insert a list item
243 .de LI
244 .  ie \\n[www-html] \
245 .    HTML "<li>"
246 .  el \{\
247 .    br
248 .    ti -\w'\\*[www-level\\n[www-level]]'
249 .    nop \\*[www-level\\n[www-level]]\c
250 .  \}
253 .\" supplementary macros used by other macro sets
255 .\" here are some tags specially for -Tps or -Thtml when invoked by pre-html
256 .\" to generate png images from postscript.
258 .\" www-do-image - tells troff to issue an image marker which can be
259 .\"                read back by pre-html
261 .de www-do-image
262 .  if r ps4html \
263 .    nop \O[3]\O[5\\$2\\$1.png]\O[0]\O[1]
264 .  if \\n[www-html] \
265 .    nop \O[3]\O[5\\$2\\$1.png]\O[0]
268 .\" HTML-IMAGE-END - terminates an image for html
270 .de HTML-IMAGE-END
271 .  if r ps4html \
272 .    nop \O[2]\O[1]\O[4]
273 .  if \\n[www-html] \
274 .    nop \O[2]\O[1]\O[4]
277 .nr www-png-no 0
280 .\" www-make-unique-name - generates another unique name in string
281 .\"                        `www-unique-name'
283 .de www-make-unique-name
284 .  nr www-png-no +1
285 .  ds www-unique-name \\n[.F]-auto-\\n[www-png-no]\"
288 .\" HTML-IMAGE - is the same name as a tag generated from eqn/tbl/pic.
289 .\"              Although the tags generated via the preprocessor
290 .\"              are given image names by pre-html and troff.
291 .\"              The macros below can only be invoked by *other macro sets*
292 .\"              not user troff input since the contents of macro sets are
293 .\"              not seen by pre-html.
295 .de HTML-IMAGE
296 .  \" generates a centered image
297 .  www-make-unique-name
298 .  www-do-image \\*[www-unique-name] c
301 .de HTML-IMAGE-RIGHT
302 .  www-make-unique-name
303 .  www-do-image \\*[www-unique-name] r
306 .de HTML-IMAGE-LEFT
307 .  www-make-unique-name
308 .  www-do-image \\*[www-unique-name] l
311 .de HTML-IMAGE-INLINE
312 .  www-make-unique-name
313 .  www-do-image \\*[www-unique-name] i
317 .if \n[www-html] \{\
318 .   nh
319 .   nr HY 0
321 .cp \n(_C
323 .\" EOF