summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorLudovic Court`es2007-06-25 08:01:12 +0000
committerLudovic Court`es2007-06-25 08:01:12 +0000
commit1abaff8201f2dd38794f1bdc64115bc82ef0a4d0 (patch)
tree160a5d9f633c6e4097836e49f7535cbd2bec476a /src
parenta96ab6b83c1754103f37cdd27b872b1e3bda95c0 (diff)
parent0987800d0caf8371a2b25e285e233bd5e7e66aec (diff)
downloadskribilo-1abaff8201f2dd38794f1bdc64115bc82ef0a4d0.tar.gz
skribilo-1abaff8201f2dd38794f1bdc64115bc82ef0a4d0.tar.lz
skribilo-1abaff8201f2dd38794f1bdc64115bc82ef0a4d0.zip
Merge from skribilo@sv.gnu.org--2006
Patches applied:

 * lcourtes@laas.fr--2005-mobile/skribilo--devel--1.2  (patch 100-109)

   - `base' engine: Fixed autoload issue.
   - Merge from skribilo@sv.gnu.org--2006/skribilo--devo--1.2
   - eq: Implemented equation numbering.
   - eq/lout: Use the new `@BypassNumber' option for numbered displays.
   - eq: Updated doc for `:number'.
   - eq/lout: Fixed spacing around in-line equations.

 * skribilo@sv.gnu.org--2006/skribilo--devo--1.2  (patch 60-121)

   - `base' engine: Fixed autoload issue.
   - evaluator: Modularized the evaluation process.
   - biblio: Adding missing `use-module'.
   - Added an experimental `diff' package.
   - `diff' package: Fixes and hacking.
   - `lout' engine: Skip lines in `color'.
   - `diff' package: Various fixes.
   - `eq' package: Added `eq:set'.
   - `diff' package: Use actual markups and writers.
   - Slightly optimized `make-string-replace'.
   - `diff' package: Compute diffs on selected options.
   - `diff' package: Preserve space around diff'd strings.
   - `diff' package: Handle commands appropriately.
   - `lout' engine: Fixed space handling with `color'.
   - `base' package: Introduced `breakable-space'.
   - doc: Documented spacing.
   - `diff' package: Use `breakable-space' instead of `~' in
     `annotated-string-diff'.
   - `diff' package: Fixed off-by-one in string diff.
   - biblio template: Small fix.
   - Added support for source location tracking.
   - Added source location tracking to various packages.
   - Moved legacy source location code to `compat'.
   - Reduced reliance on the debugging evaluator (improves performance).
   - Fixed computation of `&invocation-location'.
   - `diff' package: Added basic source location support.
   - Renamed module `(differ)' to `(diff)'.
   - Fixed `find-up'.
   - `eq' package: Properly handle auto-inlining.
   - `lncs' package: Fixed for non-LaTeX engines.
   - `eq' package: Added support for Lout's new `eq2'.
   - `diff': Included Aubrey Jaffer's fix for `diff:edits'.
   - Fixed `index'.
   - biblio: Implemented the `name+year' label style.
   - doc: Documented the `:labels' option of `the-bibliography'.
   - Resolve <command>s too.
   - eq/biblio: Small additions.
   - Fixed handling of figure numbering in `ref'.
   - Added support for Guile-Lint.
   - Started cleaning up packages using Guile-Lint.
   - Tiny Automake fix.
   - Removed useless file.
   - lib: Minor fixes that make Guile-Lint happy.
   - More package cleanups.
   - More linting.
   - Cleaned up the source code fontifiers (under `coloring').
   - Cleaned up the `biblio' modules.
   - Cleaned up the core modules.
   - Optimized `make-general-string-replace'.
   - Fixed location reporting for `verify' warnings.
   - Slight optimization/cleanup of AST traversal functions.
   - Added a `:&location' argument to `table'.
   - Switched all engines to a native Guile module.
   - Reduced dependency on `(skribilo module)'.
   - Lout engine: Work around bug with tables within floating figures.
   - Updated the top-level documentation files.
   - Fixed top-level Makefile.
   - lout engine: Export `lout-output-pdf-meta-info'.
   - `lncs' package: Prettified bibliography output.
   - eq: Implemented equation numbering.
   - eq/lout: Use the new `@BypassNumber' option for numbered displays.
   - eq: Updated doc for `:number'.
   - eq/lout: Fixed spacing around in-line equations.

git-archimport-id: lcourtes@laas.fr--2006-libre/skribilo--devo--1.2--patch-77
Diffstat (limited to 'src')
-rw-r--r--src/guile/skribilo/package/base.scm3
-rw-r--r--src/guile/skribilo/package/eq.scm34
-rw-r--r--src/guile/skribilo/package/eq/lout.scm27
3 files changed, 49 insertions, 15 deletions
diff --git a/src/guile/skribilo/package/base.scm b/src/guile/skribilo/package/base.scm
index 29eb2df..28cd0fb 100644
--- a/src/guile/skribilo/package/base.scm
+++ b/src/guile/skribilo/package/base.scm
@@ -203,7 +203,8 @@
 		 ,@(the-options opts :ident :class)))
       (body (the-body opts))
       (env (list (list 'section-counter 0) (list 'section-env '())
-		 (list 'footnote-counter 0) (list 'footnote-env '())))))
+		 (list 'footnote-counter 0) (list 'footnote-env '())
+                 (list 'equation-counter 0) (list 'equation-env '())))))
 
 ;*---------------------------------------------------------------------*/
 ;*    section-number ...                                               */
diff --git a/src/guile/skribilo/package/eq.scm b/src/guile/skribilo/package/eq.scm
index 9b03aef..31b297d 100644
--- a/src/guile/skribilo/package/eq.scm
+++ b/src/guile/skribilo/package/eq.scm
@@ -27,7 +27,8 @@
   :use-module (skribilo utils syntax)
   :use-module (skribilo utils keywords) ;; `the-options', etc.
   :autoload   (skribilo package base) (it symbol sub sup)
-  :autoload   (skribilo engine lout) (lout-illustration)
+  :autoload   (skribilo engine lout)  (lout-illustration)
+  :autoload   (skribilo resolve)      (resolve-counter)
 
   :use-module (srfi srfi-1)
   :use-module (srfi srfi-39)
@@ -207,6 +208,18 @@ a symbol representing the mathematical operator denoted by @var{m} (e.g.,
 	(current-module)))
 
 
+(define-public (equation-number-string equation)
+  "Return an appropriate document-wide number for @var{equation}."
+  (and (is-markup? equation 'eq)
+       (not (inline-equation? equation))
+       (let ((num (markup-option equation :number)))
+         (and (number? num)
+              (let ((chapter (ast-chapter equation)))
+                (and (markup? chapter)
+                     (string-append
+                      (number->string (markup-option chapter :number)) "."
+                      (number->string num))))))))
+
 
 ;;;
 ;;; Markup.
@@ -224,7 +237,8 @@ a symbol representing the mathematical operator denoted by @var{m} (e.g.,
 (define-markup (eq :rest opts :key (ident #f) (class "eq")
                                    (inline? 'auto) (align-with #f)
 		                   (renderer #f) (div-style 'over)
-                                   (mul-style 'space))
+                                   (mul-style 'space)
+                                   (number #t))
   (new container
        (markup 'eq)
        (ident (or ident (symbol->string (gensym "eq"))))
@@ -232,9 +246,23 @@ a symbol representing the mathematical operator denoted by @var{m} (e.g.,
        (loc   &invocation-location)
        (options `((:div-style ,div-style) (:align-with ,align-with)
                   (:mul-style ,mul-style) (:inline? ,inline?)
+                  (:number ,(cond ((not number)     #f)
+                                  ((string? number) number)
+                                  (else
+                                   (new unresolved
+                                      (proc (lambda (n e env)
+                                              (let* ((p? (assq 'parent env))
+                                                     (p  (and (pair? p?)
+                                                              (cadr p?))))
+                                                (and (is-markup? p 'eq)
+                                                     (not (inline-equation? p))
+                                                     (resolve-counter n env
+                                                                      'equation
+                                                                      number)))))))))
                   ,@(the-options opts
                                  :ident :class :inline?
-                                 :div-style :mul-style :align-with)))
+                                 :div-style :mul-style :align-with
+                                 :number)))
        (body (let loop ((body (the-body opts))
 			(result '()))
 	       (if (null? body)
diff --git a/src/guile/skribilo/package/eq/lout.scm b/src/guile/skribilo/package/eq/lout.scm
index 9b27a7e..577f6da 100644
--- a/src/guile/skribilo/package/eq/lout.scm
+++ b/src/guile/skribilo/package/eq/lout.scm
@@ -57,20 +57,25 @@
    :after  "\n@EndAlignedDisplays\n")
 
 (markup-writer 'eq (find-engine 'lout)
-   :options '(:inline? :align-with :div-style :mul-style)
+   :options '(:inline? :align-with :div-style :mul-style :number)
    :before (lambda (node engine)
              (let* ((parent (ast-parent node))
-                    (displayed? (is-markup? parent 'eq-display)))
-               (format #t "~a{ "
-                       (if (and displayed? (not (*embedded-renderer*)))
-                           "\n@IAD " ""))))
+                    (displayed? (is-markup? parent 'eq-display))
+                    (number (equation-number-string node)))
+               ;; Note: The `@BypassNumber' option appeared in Lout 3.36.
+               (if (and displayed? (not (*embedded-renderer*)))
+                   (display (if (string? number)
+                                (string-append "@CAND @BypassNumber { \""
+                                               number "\" } ")
+                                "@CAD ")))
+               (display "{ ")))
    :action (lambda (node engine)
-	     (display (if (inline-equation? node)
-			  "@OneRow @OneCol @E { "
-			  "@Eq { "))
-	     (let ((eq (markup-body node)))
-	       ;;(fprint (current-error-port) "eq=" eq)
-	       (output eq engine)))
+             (display (if (inline-equation? node)
+                          "@OneRow @OneCol @E { "
+                          "@Eq { "))
+             (let ((eq (markup-body node)))
+               ;;(fprint (current-error-port) "eq=" eq)
+               (output eq engine)))
    :after  " } }")