summaryrefslogtreecommitdiff
path: root/tmac
diff options
context:
space:
mode:
authorwlemb <wlemb>2003-02-25 08:54:27 +0000
committerwlemb <wlemb>2003-02-25 08:54:27 +0000
commit917c3c7c1ccaa879f7c649b74e9654c535e3a272 (patch)
treee41ce4a93eef566710cb2ef1f5c5ccc681b8d1b9 /tmac
parent13c738d1f14c49524dfefce85c51c09d2b8591ea (diff)
downloadgroff-917c3c7c1ccaa879f7c649b74e9654c535e3a272.tar.gz
* aclocal.m4 (GROFF_HTML_PROGRAMS): Add test for pnmtops.
(GROFF_PNMTOPS_NOSETPAGE): New macro. * configure.ac: Use it. * configure: Regenerated. * Makefile.in: Updated. * tmac/Makefile.sub (NORMALFILES): Remove www.tmac. (CLEANADD): Add www.tmac-sed. (pnmtops_nosetpage): Define default. (install_data): Handle www.tmac-sed and substitute @PNMTOPS_NOSETPAGE@. (stamp-sed): Add www.tmac. * tmac/www.tmac: Rewritten, based on a patch by Bernd Warken. It now breaks URLs at suitable places. (www:substring_ok): New register set by... (www:@test_substring): New macro. (www:error): New alias to www-error. (www:lenstr, www:splitstr, www:url_breaks, www:url_breaks_splitted): New macros. (URL): Use www:url_breaks. (PIMG, MPIMG): Use @PNMTOPS_NOSETPAGE@. (CDS, CDE): New macros. * src/devices/grops/ps.cc (ps_printer::define_encoding): Avoid buffer overflow.
Diffstat (limited to 'tmac')
-rw-r--r--tmac/Makefile.sub12
-rw-r--r--tmac/www.tmac355
2 files changed, 321 insertions, 46 deletions
diff --git a/tmac/Makefile.sub b/tmac/Makefile.sub
index 88544031..9f9b6f09 100644
--- a/tmac/Makefile.sub
+++ b/tmac/Makefile.sub
@@ -22,7 +22,7 @@ NORMALFILES=\
X.tmac Xps.tmac \
lj4.tmac \
lbp.tmac \
- html.tmac www.tmac \
+ html.tmac \
europs.tmac \
eqnrc \
troffrc troffrc-end \
@@ -32,13 +32,14 @@ STRIPFILES=e.tmac doc.tmac doc-old.tmac
MDOCFILES=doc-common doc-ditroff doc-nroff doc-syms
mdocdir=$(tmacdir)/mdoc
CLEANADD=\
- stamp-wrap stamp-sed *-wrap man.tmac-sed ms.tmac-sed \
+ stamp-wrap stamp-sed *-wrap man.tmac-sed ms.tmac-sed www.tmac-sed \
stamp-strip e.tmac-s doc.tmac-s doc-old.tmac-s \
doc-common-s doc-ditroff-s doc-nroff-s doc-syms-s mdoc.local-s
tmac_s_prefix=
tmac_an_prefix=
tmac_wrap=
sys_tmac_prefix=
+pnmtops_nosetpage="pnmtops"
all: stamp-strip stamp-wrap stamp-sed
@@ -64,6 +65,8 @@ install_data: $(NORMALFILES) $(SPECIALFILES) man.local \
$(INSTALL_DATA) $(srcdir)/an.tmac $(tmacdir)/$(tmac_an_prefix)an.tmac
-rm -f $(tmacdir)/man.tmac
$(INSTALL_DATA) man.tmac-sed $(tmacdir)/man.tmac
+ -rm -f $(tmacdir)/www.tmac
+ $(INSTALL_DATA) www.tmac-sed $(tmacdir)/www.tmac
for f in $(STRIPFILES); do \
rm -f $(tmacdir)/$$f; \
$(INSTALL_DATA) $$f-s $(tmacdir)/$$f; \
@@ -98,11 +101,12 @@ stamp-wrap:
fi
touch $@
-stamp-sed: man.tmac ms.tmac
- for f in man.tmac ms.tmac; do \
+stamp-sed: man.tmac ms.tmac www.tmac
+ for f in man.tmac ms.tmac www.tmac; do \
rm -f $$f-sed; \
sed -e "s;@TMAC_AN_PREFIX@;$(tmac_an_prefix);g" \
-e "s;@TMAC_S_PREFIX@;$(tmac_s_prefix);g" \
+ -e "s;@PNMTOPS_NOSETPAGE@;$(pnmtops_nosetpage);g" \
$(srcdir)/$$f > $$f-sed; \
done
touch $@
diff --git a/tmac/www.tmac b/tmac/www.tmac
index 01de668f..c7ef46ed 100644
--- a/tmac/www.tmac
+++ b/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
.
@@ -27,9 +66,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 +264,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 +348,7 @@
. nop \m[blue]\\$2\m[] \%\[la]\f[C]\\$1\f[]\[ra]\\$3
. \}
..
-.\"
+.\" --------------------------------------------------------------------
.\" TAG name
.\"
.\" Generate an html name NAME.
@@ -125,7 +356,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 +386,7 @@
. el \
. nop \[la]\f[C]\\$1\f[]\[ra]
..
-.\"
+.\" --------------------------------------------------------------------
.\" HTML-TAG
.\"
.\" Emit a tag for grohtml. This is an internal macro.
@@ -167,7 +398,7 @@
. nop \X^html-tag:\\$*^
. \}
..
-.\"
+.\" --------------------------------------------------------------------
.\" HTML-TAG-NS
.\"
.\" Emit a tag for grohtml (without a space). This is an internal macro.
@@ -176,7 +407,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 +450,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 +459,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 +508,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 +537,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 +577,7 @@
. \}
. \}
..
-.\"
+.\" --------------------------------------------------------------------
.\" HnS n
.\"
.\" Begin heading. Heading level is N.
@@ -371,7 +605,7 @@
. www-error "HnE found without a corresponding HnS"
. br
..
-.\"
+.\" --------------------------------------------------------------------
.\" LK
.\"
.\" Emit the automatically collected links derived from
@@ -380,7 +614,7 @@
.de LK
. HTML-TAG ".links"
..
-.\"
+.\" --------------------------------------------------------------------
.\" HR
.\"
.\" Produce a horizontal line
@@ -393,7 +627,7 @@
. el \
. sp
..
-.\"
+.\" --------------------------------------------------------------------
.\" NHR
.\"
.\" Suppresses the generation of the top and bottom rules which grohtml
@@ -408,7 +642,7 @@
.de www-end-nowhere
. di
..
-.\"
+.\" --------------------------------------------------------------------
.\" HTL
.\"
.\" Generate an HTML title only. This differs from the -ms .TL macro
@@ -427,6 +661,9 @@
. \}
..
.
+.\" --------------------------------------------------------------------
+.\" auxiliary definitions for ULS / ULE
+.\"
.ds www-level1 \[bu]\ \ \"
.ds www-level2 \[sq]\ \ \"
.ds www-level3 \[ci]\ \ \"
@@ -449,7 +686,7 @@
. www-error "trying to terminate a list which does not exist"
. nr www-level -1
..
-.\"
+.\" --------------------------------------------------------------------
.\" ULS
.\"
.\" Start an unordered list.
@@ -464,7 +701,7 @@
. nr www-depth +\w'\\*[www-level\\n[www-level]]'u
. \}
..
-.\"
+.\" --------------------------------------------------------------------
.\" ULE
.\"
.\" End an unordered list.
@@ -478,7 +715,7 @@
. \}
. www-pop-level
..
-.\"
+.\" --------------------------------------------------------------------
.\" LI
.\"
.\" Insert a list item.
@@ -492,7 +729,7 @@
. nop \\*[www-level\\n[www-level]]\c
. \}
..
-.\"
+.\" --------------------------------------------------------------------
.\" DC l text [color]
.\"
.\" L is the letter to be dropped and enlarged.
@@ -537,6 +774,8 @@
. \}
. nop \\$2
..
+.\" --------------------------------------------------------------------
+.\" Setup around HTML-IMAGE and friends
.\"
.\" now set up TS, TE, EQ, EN default macros
.\"
@@ -547,9 +786,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
.\"
@@ -559,7 +799,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
@@ -571,7 +811,7 @@
.
.nr www-png-no 0
.
-.\"
+.\" --------------------------------------------------------------------
.\" www-make-unique-name - generates another unique name in string
.\" `www-unique-name'
.\"
@@ -579,7 +819,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.
.\"
@@ -604,11 +844,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