aboutsummaryrefslogtreecommitdiff
path: root/g.tmac
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-06-18 16:17:12 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-06-18 16:17:12 +0200
commit427bb11eeffae931bec991b338aefeaa7ff1de76 (patch)
tree0c4f0def16e5de574b71833906eadeaf76e14a48 /g.tmac
parent9365fec1a278974b4cabc9192f0797fc5d1d1682 (diff)
downloadmk-427bb11eeffae931bec991b338aefeaa7ff1de76.tar.gz
Organize and document source code
Diffstat (limited to 'g.tmac')
-rw-r--r--g.tmac116
1 files changed, 91 insertions, 25 deletions
diff --git a/g.tmac b/g.tmac
index d995c03..3b5bbd6 100644
--- a/g.tmac
+++ b/g.tmac
@@ -1,44 +1,53 @@
-.eo
-.\" s -- setup document
+.eo \" disable backslash escapes
+.
+.\" Internal macros
+.\" ---------------
+.
+.\" _s -- setup document
.de _s
+.
. \" configure initial options
-. _nr mt 1i \" margin top
-. _nr mb 1i \" margin bottom
+. _nr mt 1i \" margin top
+. _nr mb 1i \" margin bottom
+. _ds cfam C \" inline constant-width font family
+. _ds cps -1p \" inline constant-width font size
+.
. \" initialize document
. wh 0 _h
. wh -\n(mbu _f
-. sp 1u \" trigger header
+. sp 1u \" trigger header
. ns
+.
. \" configure environments
-. _e t \" title
+. t \" title
. evc 0
. ps +4p
. vs +2p
. ft B
. ad c
-. _e n \" name (of author)
+. n \" name (of author)
. evc 0
. nr sp 0.4v
. ad c
-. _e d \" date
+. d \" date
. evc 0
. nr sp 0.4v
. ad c
-. _e h \" heading
+. h \" heading
. evc 0
. nr sp 0.6v
. ps +1p
. ft B
-. _e s \" section heading
+. s \" section heading
. evc 0
. nr sp 0.6v
. ft B
-. _e p \" paragraph
+. p \" paragraph
. evc 0
. nr sp 0.3v
. nr ti 0.5c
. ad b
-. _e c \" code listing
+. l \" literal display
. evc 0
. nr sp 0.3v
. nr in 0.5c
@@ -48,35 +57,53 @@
. ps -1p
. _e
..
+.
.\" _h -- page header
.de _h
' sp \n(mtu
..
+.
.\" _f -- page footer
.de _f
' sp 1v
. tl ''%''
' bp
..
-.\" _nr -- set default value
+.
+.\" _nr -- set default numeric value
.de _nr
. if \n[\$1]=0 .nr \$1 \$2
..
+.
+.\" _ds -- set default string value
+.de _ds
+. if '\*[\$1]'' .ds \$1 \$2
+..
+.
.\" _e -- set environment
.de _e
+.
+. \" initialize document?
. if '\n(_s'0' \{\
. nr _s 1
. _s
. \}
+.
. br
+.
+. \" save special environment variables
. if !'\n[.ev]'0' \{\
. nr \n[.ev]_sp \n(sp
. nr \n[.ev]_in \n(in
. nr \n[.ev]_ti \n(ti
. ev
. \}
+.
+. \" keep track of previous and new environment
. ds penv \*[env]
. ds env \$1
+.
+. \" activate new environment
. if !'\$1'' \{\
. ev \$1
. nr sp \n[\n[.ev]_sp]
@@ -85,41 +112,75 @@
. sp \n(spu
. in \n(inu
. \}
-. _mb
-..
-.\" _mb -- margin bottom
-.de _mb
-. ie '\*[env]'n' .return
-. el .if '\*[env]'d' .return
+.
+. \" perform post-environment operations
+. _pe
+..
+.
+.\" _pe -- post-environment operations
+.de _pe
+.
+. \" add small space after title
+. if '\*[penv]'t' \{\
+. if '\*[env]'n' .sp 0.1v
+. if '\*[env]'d' .sp 0.1v
+. \}
+.
+. \" add space after title/name/date
+. if '\*[env]'n' .return
+. if '\*[env]'d' .return
. ie '\*[penv]'t' .sp 1v
. el .ie '\*[penv]'n' .sp 1v
. el .if '\*[penv]'d' .sp 1v
..
+.
+.
+.\" Inline macros
+.\" -------------
+.
.\" i -- italic
.de i
\$3\fI\$1\fP\$2
..
+.
.\" x -- bold italic
.de x
\$3\f(BI\$1\fP\$2
..
+.
+.\" c -- constant-width
+.de c
+\$3\c
+. fam \*[cfam]
+. ps \*[cps]
+\$1\c
+. fam
+. ps
+\$2
+..
+.
.\" q -- quote
.de q
\$3\(lq\$1\(rq\$2
..
+.
+.
+.\" Environment macros
+.\" ------------------
+.
.\" t -- title
.de t
. _e t
..
+.
.\" n -- name (of author)
.de n
. _e n
-. if '\*[penv]'t' .sp 0.2v
..
+.
.\" d -- date
.de d
. _e d
-. if '\*[penv]'t' .sp 0.2v
. af mo 00
. af dy 00
. ie '\$1'' \n[year]-\n(mo-\n(dy
@@ -127,21 +188,26 @@
. af mo 1
. af dy 1
..
+.
.\" h -- heading
.de h
. _e h
+.
..
.\" s -- section heading
.de s
. _e s
+.
..
.\" p -- paragraph
.de p
. _e p
. if '\*[penv]'p' .ti \n(tiu
..
-.\" c -- code listing
-.de c
-. _e c
+.
+.\" l -- literal display
+.de l
+. _e l
..
-.ec
+.
+.ec \" re-enable backslash escapes