aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/user/sectioning.skb19
-rw-r--r--src/guile/skribilo/ast.scm36
-rw-r--r--src/guile/skribilo/engine/lout.scm6
-rw-r--r--src/guile/skribilo/package/base.scm33
4 files changed, 57 insertions, 37 deletions
diff --git a/doc/user/sectioning.skb b/doc/user/sectioning.skb
index 860821d..bea8116 100644
--- a/doc/user/sectioning.skb
+++ b/doc/user/sectioning.skb
@@ -1,6 +1,7 @@
;;; sectioning.skb -- Sectioning markups
;;;
;;; Copyright 2003, 2004 Manuel Serrano
+;;; Copyright 2007 Ludovic Courtès <ludo@gnu.org>
;;;
;;;
;;; This program is free software; you can redistribute it and/or modify
@@ -40,10 +41,12 @@
(doc-markup 'chapter
`((:title [The title of the chapter.])
- (:html-title "The title of window of the HTML browser.")
+ (:html-title [The title of window of the HTML browser.])
(:number [This argument controls the chapter number.
-A value of ,(tt "#t") means that the Skribe compiler computes the chapter
-number. A value of ,(tt "#f") means that the chapter has no number.])
+A value of ,(tt "#t") means that Skribilo computes the chapter
+number. A value of ,(tt "#f") means that the chapter has no number. A
+number or string specifies a number to be used in lieu of the
+automatically computed number.])
(:toc ,[This argument controls if the chapter must
be referenced in the ,(ref :mark "toc" :text "table of contents").])
(:file [The argument must be a boolean. A value of
@@ -73,8 +76,10 @@ in the main target file.])
(doc-markup 'section
`((:title [The title of the chapter.])
(:number [This argument controls the chapter number.
-A value of ,(tt "#t") means that the Skribe compiler computes the chapter
-number. A value of ,(tt "#f") means that the chapter has no number.])
+A value of ,(tt "#t") means that Skribilo computes the chapter
+number. A value of ,(tt "#f") means that the chapter has no number. A
+number or string specifies a number to be used in lieu of the
+automatically computed number.])
(:toc ,[This argument controls if the chapter must
be referenced in the ,(ref :mark "toc" :text "table of contents").])
(:file [The argument must be a boolean. A value of
@@ -123,4 +128,6 @@ of text.])
'((#!rest node... "The nodes of the quoted text.")))))
-
+;;; Local Variables:
+;;; coding: latin-1
+;;; End:
diff --git a/src/guile/skribilo/ast.scm b/src/guile/skribilo/ast.scm
index 1b37a0b..f515009 100644
--- a/src/guile/skribilo/ast.scm
+++ b/src/guile/skribilo/ast.scm
@@ -23,6 +23,7 @@
(define-module (skribilo ast)
:use-module (oop goops)
+ :use-module (srfi srfi-13)
:use-module (srfi srfi-34)
:use-module (srfi srfi-35)
:use-module (skribilo condition)
@@ -610,20 +611,33 @@
;; Return a structure number string such as "1.2".
(cond ((is-markup? markup 'figure)
;; Figure numbering is assumed to be document-wide.
- (number->string (markup-option markup :number)))
+ (let ((num (markup-option markup :number)))
+ (if (number? num)
+ (number->string num)
+ num)))
(else
;; Use a hierarchical numbering scheme.
- (let loop ((markup markup))
+ (let loop ((markup markup)
+ (result '()))
(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)
- ""))))))))
-
+ (string-join result sep)
+ (let ((num (markup-option markup :number)))
+ (loop (ast-parent markup)
+ (cond ((number? num)
+ (cons (number->string num)
+ result))
+ ((ast? num)
+ (cons (ast->string num)
+ result))
+ ((string? num)
+ (cons num result))
+ (else
+ result)))))))))
+
+
+;;; Local Variables:
+;;; coding: latin-1
+;;; End:
;;; arch-tag: e2489bd6-1b6d-4b03-bdfb-83cffd2f7ce7
diff --git a/src/guile/skribilo/engine/lout.scm b/src/guile/skribilo/engine/lout.scm
index a93cde7..954329c 100644
--- a/src/guile/skribilo/engine/lout.scm
+++ b/src/guile/skribilo/engine/lout.scm
@@ -1362,12 +1362,10 @@
(output title e)
(display " }\n")
- (if (number? number)
+ (if number
(format #t " @BypassNumber { ~a }\n"
(markup-number-string n))
- (if (not number)
- ;; this trick hides the section number
- (display " @BypassNumber { } # unnumbered\n")))
+ (display " @BypassNumber { } # unnumbered\n"))
(cond ((string? ident)
(begin
diff --git a/src/guile/skribilo/package/base.scm b/src/guile/skribilo/package/base.scm
index 872c1e2..9616080 100644
--- a/src/guile/skribilo/package/base.scm
+++ b/src/guile/skribilo/package/base.scm
@@ -174,6 +174,22 @@
(skribe-error 'toc "Illegal argument" body)))))))
;*---------------------------------------------------------------------*/
+;* section-number ... */
+;*---------------------------------------------------------------------*/
+(define (section-number number markup)
+ (cond ((not number)
+ ;; number-less
+ #f)
+ ((or (string? number) (list? number) (ast? number))
+ ;; user-specified number
+ number)
+ (else
+ ;; automatic numbering
+ (new unresolved
+ (proc (lambda (n e env)
+ (resolve-counter n env markup number)))))))
+
+;*---------------------------------------------------------------------*/
;* chapter ... ... */
;* ------------------------------------------------------------- */
;* doc: */
@@ -193,13 +209,7 @@
(loc &invocation-location)
(required-options '(:title :file :toc :number))
(options `((:toc ,toc)
- (:number ,(and number
- (new unresolved
- (proc (lambda (n e env)
- (resolve-counter n
- env
- 'chapter
- number))))))
+ (:number ,(section-number number 'chapter))
,@(the-options opts :ident :class)))
(body (the-body opts))
(env (list (list 'section-counter 0) (list 'section-env '())
@@ -207,15 +217,6 @@
(list 'equation-counter 0) (list 'equation-env '())))))
;*---------------------------------------------------------------------*/
-;* section-number ... */
-;*---------------------------------------------------------------------*/
-(define (section-number number markup)
- (and number
- (new unresolved
- (proc (lambda (n e env)
- (resolve-counter n env markup number))))))
-
-;*---------------------------------------------------------------------*/
;* section ... */
;* ------------------------------------------------------------- */
;* doc: */