From a85c6cc8b1f445883389fc65fa170b538291b7d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Tue, 22 Jun 2021 21:24:11 +0200 Subject: Improve toc.tmac --- toc/Makefile | 2 +- toc/example.pdf | Bin 9369 -> 9369 bytes toc/groc | 4 ++++ toc/toc | 2 -- toc/toc.tmac | 4 ++-- toc/troc | 17 +++++++++++++++++ 6 files changed, 24 insertions(+), 5 deletions(-) create mode 100755 toc/groc delete mode 100755 toc/toc create mode 100755 toc/troc (limited to 'toc') diff --git a/toc/Makefile b/toc/Makefile index 216673b..6cf0b74 100644 --- a/toc/Makefile +++ b/toc/Makefile @@ -1,2 +1,2 @@ example.pdf: example.t - ./toc example.t | groff -Tps example.t | ps2pdf - > example.pdf + ./groc -Tps example.t | ps2pdf - > example.pdf diff --git a/toc/example.pdf b/toc/example.pdf index 8241b58..a7754dd 100644 Binary files a/toc/example.pdf and b/toc/example.pdf differ diff --git a/toc/groc b/toc/groc new file mode 100755 index 0000000..80a65a2 --- /dev/null +++ b/toc/groc @@ -0,0 +1,4 @@ +#!/bin/sh +export TROFF=groff +exec=${0%groc}troc +exec "$exec" "$@" diff --git a/toc/toc b/toc/toc deleted file mode 100755 index e8de341..0000000 --- a/toc/toc +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -troff -rT=1 -zE "$@" 2>&1 diff --git a/toc/toc.tmac b/toc/toc.tmac index 83e05a0..143994e 100644 --- a/toc/toc.tmac +++ b/toc/toc.tmac @@ -10,12 +10,12 @@ . .\" to -- evaluate collected lines .de to -. if \nT=0 .rd +. if \n(to=1 .rd .. . .\" te -- collect line .de te -. if \nT>0 .tm \$* +. if \n(te=1 .tm \$* .. . .ec diff --git a/toc/troc b/toc/troc new file mode 100755 index 0000000..8577531 --- /dev/null +++ b/toc/troc @@ -0,0 +1,17 @@ +#!/bin/sh + +: ${TROFF:=troff} + +if [ ! -t 0 ]; then + f=`mktemp` + cat > "$f" + set -- "$@" "$f" +fi + +"$TROFF" -rte=1 -rto=0 -zE "$@" 2>&1 | +"$TROFF" -rte=1 -rto=1 -zE "$@" 2>&1 | +"$TROFF" -rte=0 -rto=1 "$@" +s=$? + +[ ! -t 0 ] && rm "$f" +exit $s -- cgit v1.2.3