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