From c8a470de42c0993f5d4621897f7b22887462fc32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Thu, 24 Jun 2021 01:05:39 +0200 Subject: Use Heirloom troff Mg is now tested with both GNU and Heirloom troff. --- Makefile | 5 +++-- README.pdf | Bin 91181 -> 48115 bytes README.t | 36 +++++++++++++++++++++--------------- g.tmac | 10 ++++------ hacking.pdf | Bin 24360 -> 24436 bytes hacking.t | 2 +- t/Makefile | 4 ++-- t/ne.t | 3 +-- t/t.tmac | 8 ++++---- toc/example.pdf | Bin 9369 -> 9369 bytes 10 files changed, 36 insertions(+), 32 deletions(-) diff --git a/Makefile b/Makefile index 5ffed1e..485c8e3 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,8 @@ all: README.pdf hacking.pdf hacking.pdf: hacking.t g.tmac perl -pe '$$_=`$$_` if s/^\!//' hacking.t |\ - groff -Tps | ps2pdf - > hacking.pdf + troff -x3 | dpost | ps2pdf - > hacking.pdf README.pdf: README.t g.tmac - README.pdf + TROFFONTS=/usr/pkg/share/fonts/X11/TTF/ \ + README.pdf diff --git a/README.pdf b/README.pdf index c373b6b..eed4a81 100644 Binary files a/README.pdf and b/README.pdf differ diff --git a/README.t b/README.t index fef5c88..256c03d 100644 --- a/README.t +++ b/README.t @@ -1,3 +1,6 @@ +.do xflag 3 +.papersize a4 +.fp 0 M DejaVuSansMono ttf .so g.tmac .so gx.tmac .so toc/toc.tmac @@ -18,7 +21,7 @@ . .\" configure environments .@e l -. fam M +. ft M . vs +1p .@e . @@ -27,7 +30,7 @@ .x Mg , a simple macro package for troff .d -John Ankarstr\(:om +John Ankarström .d e . .s @@ -48,10 +51,10 @@ It is designed to be easy to understand and to customize by editing the source code. .n It makes use of the extended support for environments -offered by many modern troff implementations. +offered by modern troff implementations. .n It is designed to be practically easy to use. -Macros are consistently one letter long and written in lowercase. +Macros consist of a single lowercase letter. .p While .i mg @@ -93,7 +96,7 @@ in order to see how the macro package is used in practice. .p .i Mg makes heavy use of named environments, -supported by implementations such as GNU troff and Neatroff. +supported by implementations such as GNU troff, Heirloom troff and Neatroff. Environments obliviate the need for many special registers that a macro package (and its user) would otherwise need to keep track of. For example, @@ -429,7 +432,7 @@ At the present, is nothing more than a wrapper around troff's built-in .c ev , but it may eventually be redefined in order to offer -compatibility with implementations of troff +compatibility with troff implementations without support for named environments. .p .c @e @@ -460,7 +463,7 @@ see 5.26\~\c .i Environments in the full GNU troff manual .nh -.c "info '(groff.\:info)Environments'" ). ( +.c "info \(aq(groff\:.info)Environments\(aq" ). ( .hy .) , are configured with the standard troff requests. @@ -498,9 +501,8 @@ you can switch to that environment and use the relevant troff requests: .p If you are merely configuring the environment without printing anything in it, -you can also use the -.c @e -macro: +you can also use +.c @e : .l \&.@e q \&.ps +1p @@ -531,20 +533,27 @@ or \&. \\" set header text \&. tl 'left'center'right' \&. \\" set position of page text +.ne 1 \&. sp |1i \&.. . .w s ll .se How do I redefine the page footer? +.p +To change the position of the footer: .l \&.\\" set position of footer trap \&.\\" (must be done before any macros have been called) \&.wh -1i @tf \&. +.p +To change the contents of the footer: +.l \&.de @f \&. \\" set position of footer text \&. \\" (must be below the footer trap) \&. sp |\\\\n(.pu-48p +\&. \\" set footer text \&. tl 'left'center'right' \&.. . @@ -554,8 +563,8 @@ Some macro packages have a concept of .q keeps , sections that are kept together across page breaks. .i Mg -does not define any such macros by default. -The simplest way to achieve the same is to use troff's +does not (at least yet) define any such macros by default. +The simplest solution is to use troff's .c ne request: .l @@ -646,7 +655,6 @@ macros .i toc , a script that invokes troff in three passes in order to allow a table of contents to be generated -.n .p Use .c te @@ -700,8 +708,6 @@ Thanks to the multiple passes performed by .c to can be invoked at any place in the document, including the beginning. -The macros listed above are the ones used to generate -the table of contents of this document. . .se How do I create a reference to a later page? .p diff --git a/g.tmac b/g.tmac index 69e39b2..b751607 100644 --- a/g.tmac +++ b/g.tmac @@ -34,10 +34,9 @@ . . \" set header/footer traps . wh 0 @th -. if \n(.t=\n(.p .wh -1i @tf -. -. \" trigger header -. if \n(nl=0 .@th +. if \n(nl<=0 .@th +. nr _ \n(.p-\n(nl +. if \n(.t=\n_ .wh -1i @tf . . \" configure environments . @e d \" date @@ -348,9 +347,8 @@ ___________________ . . \" switch environment and capture footnote . (e @f -. ti 9p . boxa @n -\v'-.3m'\s'\En(.s*80/100'\n(@n\s0\v'.3m'\h'2p'\c +\h'9p'\v'-.3m'\s'\En(.s*80/100'\n(@n\s0\v'.3m'\h'2p'\c .. . .\" ) -- end footnote diff --git a/hacking.pdf b/hacking.pdf index bcd4d7b..b4c3f34 100644 Binary files a/hacking.pdf and b/hacking.pdf differ diff --git a/hacking.t b/hacking.t index 590e0ed..4233794 100644 --- a/hacking.t +++ b/hacking.t @@ -15,7 +15,7 @@ Hacking on the .x mg macro package .d -John Ankarstr\[:o]m +John Ankarström . . .h diff --git a/t/Makefile b/t/Makefile index 122da6d..f278324 100644 --- a/t/Makefile +++ b/t/Makefile @@ -9,7 +9,7 @@ g.tmac: ../g.tmac .t.T: g.tmac t.tmac @echo -- $< ----------------------- - @groff -z $< + @troff -x3 $< >/dev/null .t.pdf: g.tmac t.tmac - groff -Tps $< | ps2pdf - > $@ + troff -x3 $< | dpost | ps2pdf - > $@ diff --git a/t/ne.t b/t/ne.t index bf464b3..f0434ae 100644 --- a/t/ne.t +++ b/t/ne.t @@ -15,8 +15,7 @@ macro. .\" make space at bottom of page .de @ . rs -. rt 0 -. sp \n(.pu-\n(mbu-\\$1-1u +. sp |\n(.pu-\n(mbu-\\$1-1u . nr a \\n% .. . diff --git a/t/t.tmac b/t/t.tmac index 2a04f77..223babe 100644 --- a/t/t.tmac +++ b/t/t.tmac @@ -8,16 +8,16 @@ .de assert .ec ` .ie `$1 \{\ -. tm1 " success +. tm success .\} .ec .el \{\ -. if \\nF<\\nt .tm1 " failure: +. if \\nF<\\nt .tm failure: .ec ` . ds *exp `$1 .ec -. tm1 "{ \\*[*exp] -. if !'\\*[*exp]'\\$1' . tm1 "} \\$1 +. tm { \\*[*exp] +. if !'\\*[*exp]'\\$1' . tm } \\$1 . nr f +1 . nr F \\nt .\} diff --git a/toc/example.pdf b/toc/example.pdf index a7754dd..1615176 100644 Binary files a/toc/example.pdf and b/toc/example.pdf differ -- cgit v1.2.3