aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Court`es2006-11-24 12:53:47 +0000
committerLudovic Court`es2006-11-24 12:53:47 +0000
commit4c3a84d4fd923cefc663d314d5659253101b70f9 (patch)
tree0b0c815bcb78ebeeef34088e72b3d17f2ec4e0df
parent25deac661d70aa848fb2134dc769cc9ff55c5173 (diff)
downloadskribilo-4c3a84d4fd923cefc663d314d5659253101b70f9.tar.gz
skribilo-4c3a84d4fd923cefc663d314d5659253101b70f9.tar.lz
skribilo-4c3a84d4fd923cefc663d314d5659253101b70f9.zip
`base' package: Added `numref'.
* src/guile/skribilo/package/base.scm (numref): New. git-archimport-id: lcourtes@laas.fr--2005-libre/skribilo--devo--1.2--patch-77
-rw-r--r--src/guile/skribilo/package/base.scm43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/guile/skribilo/package/base.scm b/src/guile/skribilo/package/base.scm
index bbb2a62..4c9e84c 100644
--- a/src/guile/skribilo/package/base.scm
+++ b/src/guile/skribilo/package/base.scm
@@ -1187,6 +1187,49 @@
(line (line-ref line))
(else (skribe-error 'ref "illegal reference" opts)))))
+
+;*---------------------------------------------------------------------*/
+;* numref ... */
+;*---------------------------------------------------------------------*/
+(define-markup (numref #!rest opts
+ #!key (ident #f) (text "") (page #f)
+ (separator ".") (class #f))
+ ;; Produce a numbered reference to `ident'.
+ (new unresolved
+ (proc (lambda (n e env)
+ (let* ((parent (ast-parent n))
+ (doc (ast-document n))
+ (target (document-lookup-node doc ident))
+ (number (and target
+ (markup-option target :number))))
+ (cond
+ ((not target)
+ (skribe-warning/ast 1 n 'numref
+ (format #f "can't find `ident': ")
+ ident)
+ (new markup
+ (markup 'unref)
+ (ident (symbol->string (gensym "unref")))
+ (class class)
+ (required-options '(:text))
+ (options `((kind numref)
+ ,@(the-options opts :ident :class)))
+ (body (list ident ": " (ast->file-location n)))))
+ ((unresolved? number)
+ ;; Loop until `number' is resolved.
+ n)
+ (else
+ (let ((xref
+ (ref :text
+ (list (if text text "") " "
+ (if (number? number)
+ (markup-number-string target
+ separator)
+ ""))
+ :page page
+ :handle (handle target))))
+ (resolve! xref e env)))))))))
+
;*---------------------------------------------------------------------*/
;* resolve ... */
;*---------------------------------------------------------------------*/