aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--example.mg170
-rw-r--r--example.t55
-rw-r--r--g.tmac52
4 files changed, 93 insertions, 188 deletions
diff --git a/Makefile b/Makefile
index efd8e3d..065b120 100644
--- a/Makefile
+++ b/Makefile
@@ -1,2 +1,2 @@
-example.pdf: example.mg g.tmac
- groff -Tps example.mg | ps2pdf - > example.pdf
+example.pdf: example.t g.tmac
+ groff -Tps example.t | ps2pdf - > example.pdf
diff --git a/example.mg b/example.mg
deleted file mode 100644
index 5e8d505..0000000
--- a/example.mg
+++ /dev/null
@@ -1,170 +0,0 @@
-.so g.tmac
-.t
-.x Mg ,
-a simple macro package for troff
-.n
-John Ankarström
-.d
-.p
-.i Mg
-is a simple macro package for troff with the following features:
-.p
-1.
-It is designed to be easy to understand and to customize
-by editing the source code.
-.p
-2.
-It makes use of the extended support for environments
-offered by many modern troff implementations
-(but it can be made compatible with the original troff if need be).
-.p
-3.
-It is designed to be practically easy to use.
-Macros
-are consistently one letter long and written in lowercase.
-.p
-While
-.i mg
-does provide macros for many common tasks,
-including footnotes,
-it is at the end of the day an idiosyncratic macro package,
-written to serve the author's personal needs.
-Users of
-.i mg
-are encouraged to modify the source code
-according to their own needs.
-.p
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
-eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
-nisi ut aliquip ex ea commodo consequat.
-Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
-cupidatat non proident, sunt in culpa qui officia deserunt mollit
-anim id est laborum.
-.p
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
-eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
-nisi ut aliquip ex ea commodo consequat.
-Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
-cupidatat non proident, sunt in culpa qui officia deserunt mollit
-anim id est laborum.
-.p
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
-eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
-nisi ut aliquip ex ea commodo consequat.
-Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
-cupidatat non proident, sunt in culpa qui officia deserunt mollit
-anim id est laborum.
-.p
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
-eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
-nisi ut aliquip ex ea commodo consequat.
-Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
-cupidatat non proident, sunt in culpa qui officia deserunt mollit
-anim id est laborum.
-.p
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
-eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
-nisi ut aliquip ex ea commodo consequat.
-Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
-cupidatat non proident, sunt in culpa qui officia deserunt mollit
-anim id est laborum.
-.p
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
-eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
-nisi ut aliquip ex ea commodo consequat.
-Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
-cupidatat non proident, sunt in culpa qui officia deserunt mollit
-anim id est laborum.
-.p
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
-eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
-nisi ut aliquip ex ea commodo consequat.
-Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
-cupidatat non proident, sunt in culpa qui officia deserunt mollit
-anim id est laborum.
-.p
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
-eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
-nisi ut aliquip ex ea commodo consequat.
-Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
-cupidatat non proident, sunt in culpa qui officia deserunt mollit
-anim id est laborum.
-.p
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
-eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
-nisi ut aliquip ex ea commodo consequat.
-Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
-cupidatat non proident, sunt in culpa qui officia deserunt mollit
-anim id est laborum.
-.p
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
-eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
-nisi ut aliquip ex ea commodo consequat.
-Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
-cupidatat non proident, sunt in culpa qui officia deserunt mollit
-anim id est laborum.
-.p
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
-eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
-nisi ut aliquip ex ea commodo consequat.
-Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
-cupidatat non proident, sunt in culpa qui officia deserunt mollit
-anim id est laborum.
-.p
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
-eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
-nisi ut aliquip ex ea commodo consequat.
-Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
-cupidatat non proident, sunt in culpa qui officia deserunt mollit
-anim id est laborum.
-.p
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
-eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
-nisi ut aliquip ex ea commodo consequat.
-Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
-cupidatat non proident, sunt in culpa qui officia deserunt mollit
-anim id est laborum.
-.p
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
-eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
-nisi ut aliquip ex ea commodo consequat.
-Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
-cupidatat non proident, sunt in culpa qui officia deserunt mollit
-anim id est laborum.
-.p
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
-eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
-nisi ut aliquip ex ea commodo consequat.
-Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
-cupidatat non proident, sunt in culpa qui officia deserunt mollit
-anim id est laborum.
diff --git a/example.t b/example.t
new file mode 100644
index 0000000..3ca19bb
--- /dev/null
+++ b/example.t
@@ -0,0 +1,55 @@
+.so g.tmac
+.s
+.t
+.x Mg ,
+a simple macro package for troff
+.n
+John Ankarstr\[u00F6]m
+.d
+.p
+.i Mg
+is a simple macro package for troff with the following features:
+.p
+1.
+It is designed to be easy to understand and to customize
+by editing the source code.
+.p
+2.
+It makes use of the extended support for environments
+offered by many modern troff implementations
+(but it can be made compatible with the original troff if need be).
+.p
+3.
+It is designed to be practically easy to use.
+Macros are consistently one letter long and written in lowercase.
+.p
+While
+.i mg
+does provide macros for many common tasks,
+including footnotes,
+it is at the end of the day an idiosyncratic macro package,
+written to serve the author's personal needs.
+Users of
+.i mg
+are encouraged to modify the source code
+according to their own needs.
+.h
+Internal design
+.p
+.i Mg
+makes heavy use of named environments,
+supported by implementations such as GNU troff and Neatroff.
+Environments obliviate the need for many special registers
+that a macro package would need to keep track of.
+For example,
+.i ms
+keeps track of the document's font size in the PS register.
+.i Mg ,
+on the other hand,
+simply sets the font size inside the environment named
+.i p
+(for paragraph).
+If the user wishes to modify the default font size,
+he or she can simply switch to the
+.i p
+environment and set the font size as desired.
diff --git a/g.tmac b/g.tmac
index 2873fb8..9f80429 100644
--- a/g.tmac
+++ b/g.tmac
@@ -1,29 +1,38 @@
.eo
-.\" _s -- setup document (configurable)
-.de _s
+.\" s -- setup document
+.de s
+. \" configure initial options
+. _nr mt 1i \" margin top
+. _nr mb 1i \" margin bottom
+. \" initialize document
. wh 0 _h
-. wh -1i _f
-. sp 1u \" trigger _h
+. wh -\n(mbu _f
+. sp 1u \" trigger header
. ns
+. \" configure environments
. _e t \" title
. ps +4p
. vs +2p
. ft B
. ad c
. _e n \" name (of author)
-. nr n_mt 0.9v
+. _nr n_mt 0.4v
. ad c
. _e d \" date
-. nr d_mt 0.4v
+. _nr d_mt 0.4v
. ad c
. _e p \" paragraph
-. nr p_mt 0.3v
+. _nr p_mt 0.3v
. ad b
+. _e h \" heading
+. _nr h_mt 0.6v
+. ps +1p
+. ft B
. _e
..
.\" _h -- page header
.de _h
-' sp 1i
+' sp \n(mtu
..
.\" _f -- page footer
.de _f
@@ -31,6 +40,10 @@
. tl ''%''
' bp
..
+.\" _nr -- set default value
+.de _nr
+. if \n[\$1]=0 .nr \$1 \$2
+..
.\" _e -- set environment
.de _e
. br
@@ -39,6 +52,14 @@
. ds env \$1
. if !'\$1'' .ev \$1
..
+.\" i -- italic
+.de i
+\$3\fI\$1\fP\$2
+..
+.\" x -- bold italic
+.de x
+\$3\f(BI\$1\fP\$2
+..
.\" t -- title
.de t
. _e t
@@ -47,12 +68,14 @@
.de n
. br
. _e n
+. if '\*[penv]'t' .sp 0.2v
. sp \n[n_mt]u
..
.\" d -- date
.de d
. br
. _e d
+. if '\*[penv]'t' .sp 0.2v
. sp \n[d_mt]u
. af mo 00
. af dy 00
@@ -71,13 +94,10 @@
. el .sp \n[p_mt]u
. if '\*[penv]'p' \h'0.5c'
..
-.\" i -- italic
-.de i
-\$3\fI\$1\fP\$2
-..
-.\" x -- bold italic
-.de x
-\$3\f(BI\$1\fP\$2
+.\" h -- heading
+.de h
+. br
+. _e h
+. sp \n[h_mt]u
..
.ec
-._s