summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLudovic Court`es2006-07-28 16:06:38 +0000
committerLudovic Court`es2006-07-28 16:06:38 +0000
commit87c848ecb4e6adcc475d0fb1dbbcd124e2bd18c3 (patch)
treeb3d119079a3f137e526f4eab27d5ca16c1430638 /src
parentf9d6b7ca101444e7d278ea821a93e4b6172ff4bb (diff)
downloadskribilo-87c848ecb4e6adcc475d0fb1dbbcd124e2bd18c3.tar.gz
skribilo-87c848ecb4e6adcc475d0fb1dbbcd124e2bd18c3.tar.lz
skribilo-87c848ecb4e6adcc475d0fb1dbbcd124e2bd18c3.zip
Fixed `ref' for references by title (`:chapter', `:section', etc.).
* src/guile/skribilo/package/base.scm (ref)[doref]: Renamed to `do-ident-ref'. [do-title-ref]: New. Originally, default identifiers for chapters, sections, etc. in Skribe were the `:title' option passed through `ast->string'. However, now (it's been a while actually), default identifiers for chapters, etc., are random (returned by `gensym') so the assumption that default identifiers are title no longer holds. Hence the distinction between `do-ident-ref' and `do-title-ref'. * do/user/links.skb (ref): Clarified the doc of `:chapter' et al. git-archimport-id: lcourtes@laas.fr--2005-libre/skribilo--devo--1.2--patch-34
Diffstat (limited to 'src')
-rw-r--r--src/guile/skribilo/package/base.scm42
1 files changed, 33 insertions, 9 deletions
diff --git a/src/guile/skribilo/package/base.scm b/src/guile/skribilo/package/base.scm
index 7b97c5d..8f484a0 100644
--- a/src/guile/skribilo/package/base.scm
+++ b/src/guile/skribilo/package/base.scm
@@ -1061,7 +1061,31 @@
(required-options '(:text))
(options `((kind handle) ,@(the-options opts :ident :class)))
(body text)))
- (define (doref text kind)
+ (define (do-title-ref title kind)
+ (if (not (string? title))
+ (skribe-type-error 'ref "illegal reference" title "string")
+ (new unresolved
+ (proc (lambda (n e env)
+ (let* ((doc (ast-document n))
+ (s (find1-down
+ (lambda (n)
+ (and (is-markup? n kind)
+ (equal? (markup-option n :title)
+ title)))
+ doc)))
+ (if s
+ (new markup
+ (markup 'ref)
+ (ident (symbol->string 'title-ref))
+ (class class)
+ (required-options '(:text))
+ (options `((kind ,kind)
+ (mark ,title)
+ ,@(the-options opts :ident :class)))
+ (body (new handle
+ (ast s))))
+ (unref n title (or kind 'title)))))))))
+ (define (do-ident-ref text kind)
(if (not (string? text))
(skribe-type-error 'ref "Illegal reference" text "string")
(new unresolved
@@ -1070,7 +1094,7 @@
(if s
(new markup
(markup 'ref)
- (ident (symbol->string 'ref))
+ (ident (symbol->string 'indent-ref))
(class class)
(required-options '(:text))
(options `((kind ,kind)
@@ -1150,17 +1174,17 @@
(cond
(skribe (skribe-ref skribe))
(handle (handle-ref handle))
- (ident (doref ident #f))
- (chapter (doref chapter 'chapter))
- (section (doref section 'section))
- (subsection (doref subsection 'subsection))
- (subsubsection (doref subsubsection 'subsubsection))
- (figure (doref figure 'figure))
+ (ident (do-ident-ref ident #f))
+ (chapter (do-title-ref chapter 'chapter))
+ (section (do-title-ref section 'section))
+ (subsection (do-title-ref subsection 'subsection))
+ (subsubsection (do-title-ref subsubsection 'subsubsection))
+ (figure (do-ident-ref figure 'figure))
(mark (mark-ref mark))
(bib (bib-ref bib))
(url (url-ref))
(line (line-ref line))
- (else (skribe-error 'ref "Illegal reference" opts)))))
+ (else (skribe-error 'ref "illegal reference" opts)))))
;*---------------------------------------------------------------------*/
;* resolve ... */