aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLudovic Courtès2009-05-26 18:33:59 +0200
committerLudovic Courtès2009-05-26 18:33:59 +0200
commitce8f50fbd147864d795eb3d4869ce01ed82dcb1a (patch)
treefd60ae735f2406cd6428a9d87999997504618fe6 /src
parent9a8581b9b056efed763fb6beff15f9d36cf07ee0 (diff)
downloadskribilo-ce8f50fbd147864d795eb3d4869ce01ed82dcb1a.tar.gz
skribilo-ce8f50fbd147864d795eb3d4869ce01ed82dcb1a.tar.lz
skribilo-ce8f50fbd147864d795eb3d4869ce01ed82dcb1a.zip
Fix node binding in sub-documents returned from unresolved nodes.
* src/guile/skribilo/resolve.scm (do-resolve!<unresolved>): Bind sub-nodes of RES in the innermost document rather than in the root document. * tests/resolve.test ("resolved nested document bindings"): New test.
Diffstat (limited to 'src')
-rw-r--r--src/guile/skribilo/resolve.scm39
1 files changed, 29 insertions, 10 deletions
diff --git a/src/guile/skribilo/resolve.scm b/src/guile/skribilo/resolve.scm
index 062161f..2073f25 100644
--- a/src/guile/skribilo/resolve.scm
+++ b/src/guile/skribilo/resolve.scm
@@ -1,6 +1,6 @@
;;; resolve.scm -- Skribilo reference resolution.
;;;
-;;; Copyright 2005, 2006, 2008 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright 2005, 2006, 2008, 2009 Ludovic Courtès <ludo@gnu.org>
;;; Copyright 2003, 2004 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
;;;
;;;
@@ -202,15 +202,34 @@
(let* ((proc (slot-ref node 'proc))
(res (proc node engine env))
- (loc (ast-loc node))
- (doc (ast-document node)))
- (ast-fold (lambda (node result)
- (if (markup? node)
- (document-bind-node! doc node))
- (if (ast? node)
- (ast-loc-set! node loc)))
- #t ;; unused
- res)
+ (loc (ast-loc node)))
+
+ ;; Bind non-unresolved children of RES now so that unresolved
+ ;; children of RES (if any) can look them up in the next `resolve!'
+ ;; run. (XXX: This largely duplicated `document-bind-nodes!'.)
+ (let loop ((node res)
+ (doc (ast-document node)))
+ (if (ast? node)
+ (ast-loc-set! node loc))
+
+ (cond ((document? node)
+ ;; Bind NODE in its parent's document. This is so
+ ;; that (i) a sub-document is bound in its parent
+ ;; document, and (ii) a node within a sub-document
+ ;; is bound in this sub-document.
+ (document-bind-node! doc node)
+ (loop (markup-body node) node))
+
+ ((markup? node)
+ (document-bind-node! doc node)
+ (loop (markup-body node) doc))
+
+ ((pair? node)
+ (for-each (lambda (n) (loop n doc)) node))
+
+ ((command? node)
+ (loop (command-body node) doc))))
+
(debug-item "res=" res)
(*unresolved* #t)
res))))