diff options
author | Ludovic Courtes | 2006-11-25 17:41:04 +0000 |
---|---|---|
committer | Ludovic Courtes | 2006-11-25 17:41:04 +0000 |
commit | 2415df2ae4716bec5ca0d9605116c43d0977ea30 (patch) | |
tree | 0b0c815bcb78ebeeef34088e72b3d17f2ec4e0df /src | |
parent | 45b606578f7bae67ee92ca77b894d71a3ebab82a (diff) | |
download | skribilo-2415df2ae4716bec5ca0d9605116c43d0977ea30.tar.gz skribilo-2415df2ae4716bec5ca0d9605116c43d0977ea30.tar.lz skribilo-2415df2ae4716bec5ca0d9605116c43d0977ea30.zip |
`base' package: Added `numref'.
* src/guile/skribilo/package/base.scm (numref): New.
git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-19
Diffstat (limited to 'src')
-rw-r--r-- | src/guile/skribilo/package/base.scm | 43 |
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 ... */ ;*---------------------------------------------------------------------*/ |