changeset 151:ff3a6a0e6255

Added system for references within the document. Macros: .Id and .Cf. ``.Id foo'' places a marker at that place. ``.Cf foo'' puts the section number of the marked place there. ``.Cf foo.page'' puts the page number of the marked place there.
author markus schnalke <meillo@marmaro.de>
date Fri, 06 Jul 2012 14:59:08 +0200
parents 472aa79f9b6f
children 1b9bdc178610
files .hgignore makefile style
diffstat 3 files changed, 19 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Fri Jul 06 10:13:55 2012 +0200
+++ b/.hgignore	Fri Jul 06 14:59:08 2012 +0200
@@ -9,3 +9,4 @@
 thesis.pdf
 
 *.ig
+refs/
--- a/makefile	Fri Jul 06 10:13:55 2012 +0200
+++ b/makefile	Fri Jul 06 14:59:08 2012 +0200
@@ -7,7 +7,7 @@
 
 all: $(NAME).ps
 
-$(NAME).ps: $(CHAPS) makefile bib rfcs toc.ig
+$(NAME).ps: $(CHAPS) makefile bib rfcs toc.ig refs
 	export TROFFONTS=fonts;\
 	soelim $(CHAPS) | $(REFER) | \
 		grap | pic | troff -Tps -ms 2>err.ig | dpost >$@
@@ -20,6 +20,13 @@
 toc.ig: err.ig
 	sed -n '/^TOC____/s///p' err.ig >$@
 
+refs: err.ig
+	awk '/^REF____/{ \
+		sub(/^REF____/,""); \
+		printf $$2 >"refs/"$$1; close("refs/$$1"); \
+		printf $$3 >"refs/"$$1".page"; close("refs/$$1.page");\
+	}' err.ig
+
 pdf: $(NAME).pdf
 $(NAME).pdf: $(NAME).ps
 	ps2pdf $(PDFFLAGS) $(NAME).ps 2>/dev/null
@@ -32,6 +39,7 @@
 
 clean:
 	rm -f $(NAME).ps $(NAME).pdf book.ps book.pdf
+	rm -f refs/*
 	rm -f *.ig
 
 spell:
--- a/style	Fri Jul 06 10:13:55 2012 +0200
+++ b/style	Fri Jul 06 14:59:08 2012 +0200
@@ -410,6 +410,13 @@
 .CW "\\*(_t" "]\\$2
 ..
 
-.de Cf  \" cf. (ref within document)
-(\(-> \\$1)\\$2
+.	\" Cf - reference within the document ($1=name of ref file)
+.de Cf
+\.if !\\nZ .so refs/\\$1 \c
+\\$2
 ..
+
+.	\" Id - put a referenceable marker here ($1=identifier)
+.de Id
+.tm REF____\\$1\t\\*(SN\t\\n(PN
+..