summaryrefslogtreecommitdiff
path: root/contrib/pdfmark
diff options
context:
space:
mode:
authorkeithmarshall <keithmarshall>2007-04-11 22:23:48 +0000
committerkeithmarshall <keithmarshall>2007-04-11 22:23:48 +0000
commit588d8cd632e19eb367ed5b9f9e1cfdfa0c6b4891 (patch)
tree5beff63621971ebe4dc31bb02911a249e2f61046 /contrib/pdfmark
parent8d471b152225636925b9dcdd4c75079eb0564752 (diff)
downloadgroff-588d8cd632e19eb367ed5b9f9e1cfdfa0c6b4891.tar.gz
* pdfmark.tmac (pdfbookmark): Don't evaluate within diversions; defer
placement until diversion is copied out at top level.
Diffstat (limited to 'contrib/pdfmark')
-rw-r--r--contrib/pdfmark/ChangeLog5
-rw-r--r--contrib/pdfmark/pdfmark.tmac77
2 files changed, 51 insertions, 31 deletions
diff --git a/contrib/pdfmark/ChangeLog b/contrib/pdfmark/ChangeLog
index d2803fab..b670b28e 100644
--- a/contrib/pdfmark/ChangeLog
+++ b/contrib/pdfmark/ChangeLog
@@ -1,3 +1,8 @@
+2007-04-11 Keith Marshall <keith.d.marshall@ntlworld.com>
+
+ * pdfmark.tmac (pdfbookmark): Don't evaluate within diversions; defer
+ placement until diversion is copied out at top level.
+
2006-07-30 Keith Marshall <keith.d.marshall@ntlworld.com>
* pdfroff.sh (PDFROFF_KILL_NULL_PAGES): Require `%%BeginPageSetup' on
diff --git a/contrib/pdfmark/pdfmark.tmac b/contrib/pdfmark/pdfmark.tmac
index c8d4d27d..71ea5a34 100644
--- a/contrib/pdfmark/pdfmark.tmac
+++ b/contrib/pdfmark/pdfmark.tmac
@@ -3,7 +3,7 @@
pdfmark.tmac
-Copyright (C) 2004, 2005, 2006
+Copyright (C) 2004, 2005, 2006, 2007
Free Software Foundation, Inc.
Written by Keith Marshall (keith.d.marshall@ntlworld.com)
@@ -661,41 +661,56 @@ ps:exec \\*[pdf:composed.line]
.\" $3 = suffix for PDF internal bookmark name (optional)
.\" ------------------------------------------------------------------
.\"
-.if \\n[PDFOPMODE] \{\
+.ie '\\n(.z'' \{\
.\"
-.\" Make the bookmark name "untagged" by default,
-.\" then parse any specified options, to set a "tag", if required
+.\" When we are at the top diversion level, i.e. actually emitting text
+.\" to the output device stream, then we compute the location of, and
+.\" plant this bookmark immediately.
.\"
-. ds pdf:href-T
-. while dpdf:href.opt\\$1 \{\
-. pdf:href.opt\\$1 \\$@
-. shift \\n[pdf:href.argc]
+. if \\n[PDFOPMODE] \{\
+. \"
+. \" Make the bookmark name "untagged" by default,
+. \" then parse any specified options, to set a "tag", if required
+. \"
+. ds pdf:href-T
+. while dpdf:href.opt\\$1 \{\
+. pdf:href.opt\\$1 \\$@
+. shift \\n[pdf:href.argc]
+. \}
+. rr pdf:href.argc
+. \"
+. \" If we found "--" to mark the end of the options, discard it
+. \"
+. if '\\$1'--' .shift
+. \"
+. \" Synchronise the bookmark cache
+. \" to the requested bookmark nesting level
+. \"
+. pdf:bm.sync \\$1
+. shift
+. \"
+. \" Increment the bookmark serialisation index
+. \" in order to generate a uniquely serialised bookmark name,
+. \" ( which we return in the string "PDFBOOKMARK.NAME" ),
+. \" and insert this bookmark into the cache
+. \"
+. pdf:href.sety
+. nr pdf:bm.nr +1
+. ds PDFBOOKMARK.NAME pdf:bm\\n[pdf:bm.nr]\\*[pdf:href-T]
+. ds pdf:bm\\n[pdf:bm.nr] /Dest /\\*[PDFBOOKMARK.NAME]
+. pdfmark \\*[pdf:bm\\n[pdf:bm.nr]] /View [\\*[PDFBOOKMARK.VIEW]] /DEST
+. as pdf:bm\\n[pdf:bm.nr] " /Title (\\$*)
+. pdf:href.options.clear
+. rr PDFPAGE.Y
. \}
-. rr pdf:href.argc
-.\"
-.\" If we found "--" to mark the end of the options, discard it
-.\"
-. if '\\$1'--' .shift
-.\"
-.\" Synchronise the bookmark cache
-.\" to the requested bookmark nesting level
+. \}
+.el \{\
.\"
-. pdf:bm.sync \\$1
-. shift
+.\" But when we are collecting a diversion which will be written out later,
+.\" then we must defer bookmark placement, until we emit the diversion.
+.\" (don't rely on $0 == pdfbookmark here; it may be a volatile alias).
.\"
-.\" Increment the bookmark serialisation index
-.\" in order to generate a uniquely serialised bookmark name,
-.\" ( which we return in the string "PDFBOOKMARK.NAME" ),
-.\" and insert this bookmark into the cache
-.\"
-. pdf:href.sety
-. nr pdf:bm.nr +1
-. ds PDFBOOKMARK.NAME pdf:bm\\n[pdf:bm.nr]\\*[pdf:href-T]
-. ds pdf:bm\\n[pdf:bm.nr] /Dest /\\*[PDFBOOKMARK.NAME]
-. pdfmark \\*[pdf:bm\\n[pdf:bm.nr]] /View [\\*[PDFBOOKMARK.VIEW]] /DEST
-. as pdf:bm\\n[pdf:bm.nr] " /Title (\\$*)
-. pdf:href.options.clear
-. rr PDFPAGE.Y
+. nop \!.pdfbookmark \\$@
. \}
..
.\"