aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--doc/user/links.skb14
-rw-r--r--src/guile/skribilo/package/base.scm42
2 files changed, 40 insertions, 16 deletions
diff --git a/doc/user/links.skb b/doc/user/links.skb
index b454f28..96c5222 100644
--- a/doc/user/links.skb
+++ b/doc/user/links.skb
@@ -76,13 +76,13 @@ section, to bibliographic entries, to source code line number, etc.])
(:mark [A string that is the name of a mark. That mark has
been introduced by a ,(markup-ref "mark") markup.])
(:handle [A Skribe node ,(markup-ref "handle").])
- (:ident [A reference to a node who has been specified
- an ,(param :ident) value.])
- (:figure [The name of a ,(markup-ref "figure").])
- (:chapter [The name of a ,(markup-ref "chapter").])
- (:section [The name of a ,(markup-ref "section").])
- (:subsection [The name of a ,(markup-ref "subsection").])
- (:subsubsection [The name of a ,(markup-ref "subsubsection").])
+ (:ident [The identifier of a node (which was specified
+ as an ,(param :ident) value).])
+ (:figure [The identifier of a ,(markup-ref "figure").])
+ (:chapter [The title of a ,(markup-ref "chapter").])
+ (:section [The title of a ,(markup-ref "section").])
+ (:subsection [The title of a ,(markup-ref "subsection").])
+ (:subsubsection [The title of a ,(markup-ref "subsubsection").])
(:page [A boolean enabling/disabling page reference.])
(:bib ,[A name or a list of names of
,(ref :chapter "Bibliographies" :text "bibliographic") entry.])
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 ... */