diff options
author | Ludovic Court`es | 2007-06-05 17:05:42 +0000 |
---|---|---|
committer | Ludovic Court`es | 2007-06-05 17:05:42 +0000 |
commit | 70d48ed1c85a92cae47287887fc294ca8803d52b (patch) | |
tree | a7bb757972452f8b25d761e512e38e2851ef32ec | |
parent | 5755d7cda593b4bec3d51841fbc1223f3b7768c6 (diff) | |
parent | 5617d303ebb53291567f5b8199afb2d95db8e89b (diff) | |
download | skribilo-70d48ed1c85a92cae47287887fc294ca8803d52b.tar.gz skribilo-70d48ed1c85a92cae47287887fc294ca8803d52b.tar.lz skribilo-70d48ed1c85a92cae47287887fc294ca8803d52b.zip |
Fixed handling of figure numbering in `ref'.
* src/guile/skribilo/ast.scm (markup-number-string): Don't use a
hierarchical numbering scheme for figures.
* src/guile/skribilo/engine/lout.scm (ref): Use `markup-number-string'
rather than `@NumberOf' to determine the number of a figure. This
guarantees numbering consistency.
git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-96
-rw-r--r-- | ChangeLog | 22 | ||||
-rw-r--r-- | src/guile/skribilo/ast.scm | 23 | ||||
-rw-r--r-- | src/guile/skribilo/engine/lout.scm | 39 |
3 files changed, 56 insertions, 28 deletions
@@ -2,6 +2,28 @@ # arch-tag: automatic-ChangeLog--skribilo@sv.gnu.org--2006/skribilo--devo--1.2 # +2007-06-05 17:05:42 GMT Ludovic Court`es <ludovic.courtes@laas.fr> patch-96 + + Summary: + Fixed handling of figure numbering in `ref'. + Revision: + skribilo--devo--1.2--patch-96 + + * src/guile/skribilo/ast.scm (markup-number-string): Don't use a + hierarchical numbering scheme for figures. + + * src/guile/skribilo/engine/lout.scm (ref): Use `markup-number-string' + rather than `@NumberOf' to determine the number of a figure. This + guarantees numbering consistency. + + modified files: + ChangeLog src/guile/skribilo/ast.scm + src/guile/skribilo/engine/lout.scm + + new patches: + lcourtes@laas.fr--2006-libre/skribilo--devo--1.2--patch-55 + + 2007-06-01 17:59:55 GMT Ludovic Court`es <ludovic.courtes@laas.fr> patch-95 Summary: diff --git a/src/guile/skribilo/ast.scm b/src/guile/skribilo/ast.scm index 534b832..e60957c 100644 --- a/src/guile/skribilo/ast.scm +++ b/src/guile/skribilo/ast.scm @@ -608,14 +608,21 @@ (define* (markup-number-string markup :optional (sep ".")) ;; Return a structure number string such as "1.2". - (let loop ((markup markup)) - (if (document? markup) - "" - (let ((parent-num (loop (ast-parent markup))) - (num (markup-option markup :number))) - (string-append parent-num - (if (string=? "" parent-num) "" sep) - (if (number? num) (number->string num) "")))))) + (cond ((is-markup? markup 'figure) + ;; Figure numbering is assumed to be document-wide. + (number->string (markup-option markup :number))) + (else + ;; Use a hierarchical numbering scheme. + (let loop ((markup markup)) + (if (document? markup) + "" + (let ((parent-num (loop (ast-parent markup))) + (num (markup-option markup :number))) + (string-append parent-num + (if (string=? "" parent-num) "" sep) + (if (number? num) + (number->string num) + "")))))))) ;;; arch-tag: e2489bd6-1b6d-4b03-bdfb-83cffd2f7ce7 diff --git a/src/guile/skribilo/engine/lout.scm b/src/guile/skribilo/engine/lout.scm index e00d213..aebde57 100644 --- a/src/guile/skribilo/engine/lout.scm +++ b/src/guile/skribilo/engine/lout.scm @@ -2441,30 +2441,25 @@ ;* ref ... @label ref@ */ ;*---------------------------------------------------------------------*/ (markup-writer 'ref - :options '(:text :chapter :section :subsection :subsubsection - :figure :mark :handle :ident :page) + :options '(:text :page text kind + :chapter :section :subsection :subsubsection + :figure :mark :handle :ident) + :action (lambda (n e) - (let ((url (markup-option n :url)) - (text (markup-option n :text)) - (mark (markup-option n :mark)) - (handle (markup-option n :handle)) - (chapter (markup-option n :chapter)) - (section (markup-option n :section)) - (subsection (markup-option n :subsection)) - (subsubsection (markup-option n :subsubsection)) + (let ((ident (markup-option n 'text)) + (kind (markup-option n 'kind)) + (text (markup-option n :text)) (show-page-num? (markup-option n :page))) - ;; A handle to the target is automagically passed - ;; as the body of each `ref' instance (see `api.scm'). + ;; A handle to the target is passed as the body of each + ;; `ref' instance (see `package/base.scm'). (let* ((target (handle-ast (markup-body n))) - (ident (markup-ident target)) - (title (markup-option target :title)) - (number (markup-option target :number))) + (title (markup-option target :title))) (lout-debug "ref: target=~a ident=~a" target ident) (if text (output text e)) ;; Marks don't have a number - (if (eq? (markup-markup target) 'mark) + (if (eq? kind 'mark) (printf (lout-page-of ident)) (begin ;; Don't output a section/whatever number @@ -2474,10 +2469,14 @@ ;; we don't even know how to reference them ;; anyway. (if (not text) - (printf " @NumberOf { ~a }" - (lout-tagify ident))) - (if show-page-num? - (printf (lout-page-of ident))))))))) + (let ((number + (if (eq? kind 'figure) + (markup-option target :number) + (markup-number-string target)))) + (display " ") + (display number)) + (if show-page-num? + (printf (lout-page-of ident)))))))))) ;*---------------------------------------------------------------------*/ |