about summary refs log tree commit diff
path: root/src/guile/skribilo/engine
diff options
context:
space:
mode:
authorLudovic Court`es2007-05-04 13:47:41 +0000
committerLudovic Court`es2007-05-04 13:47:41 +0000
commitde80f75d76d16144ddd3929a09463df0a341846c (patch)
tree2a9710311c9de1998a12c2cebd21878cedb9afc7 /src/guile/skribilo/engine
parent3ee5b5750f0b0b29ca2ee13c3cb1f1c9cbe18e25 (diff)
parentf18224ad16296c276583368e9572bced7a57bb53 (diff)
downloadskribilo-de80f75d76d16144ddd3929a09463df0a341846c.tar.gz
skribilo-de80f75d76d16144ddd3929a09463df0a341846c.tar.lz
skribilo-de80f75d76d16144ddd3929a09463df0a341846c.zip
biblio: Implemented the `name+year' label style.
* src/guile/skribilo/biblio.scm: Use `biblio author'.
  (assign-entries-numbers!): New (formerly `count!' in `resolve-the-bib').
  (assign-entries-name+years!): New.
  (resolve-the-bib): New optional `assign-entries-identifiers!' argument.
  Use it.

* src/guile/skribilo/biblio/author.scm (short-author-names): New.

* src/guile/skribilo/engine/lout.scm (lout-bib-refs-sort/number): Accept
  non-number identifiers.
  (&the-bibliography): Use simply `@TaggedList' when a style other than
  `number' is used.
  (&bib-entry): Use `@DropTagItem' when the bibliography style is not
  `number'.

* src/guile/skribilo/package/base.scm (the-bibliography): New `:labels'
  option.  Pass the right label assignment function to `resolve-the-bib'.

--This line, and those below, will be ignored--
Files to commit:
   src/guile/skribilo/package/base.scm
   src/guile/skribilo/engine/lout.scm
   src/guile/skribilo/biblio.scm
   doc/user/bib.skb
   src/guile/skribilo/biblio/author.scm

This list might be incomplete or outdated if editing the log
message was not invoked from an up-to-date changes buffer!

git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-92
Diffstat (limited to 'src/guile/skribilo/engine')
-rw-r--r--src/guile/skribilo/engine/lout.scm104
1 files changed, 61 insertions, 43 deletions
diff --git a/src/guile/skribilo/engine/lout.scm b/src/guile/skribilo/engine/lout.scm
index 4648217..e00d213 100644
--- a/src/guile/skribilo/engine/lout.scm
+++ b/src/guile/skribilo/engine/lout.scm
@@ -1,6 +1,7 @@
 ;;; lout.scm  --  A Lout engine.
 ;;;
-;;; Copyright 2004, 2005, 2006  Ludovic Courtès <ludovic.courtes@laas.fr>
+;;; Copyright 2004, 2005, 2006, 2007
+;;; Ludovic Courtès <ludovic.courtes@laas.fr>
 ;;;
 ;;;
 ;;; This program is free software; you can redistribute it and/or modify
@@ -21,6 +22,8 @@
 ;;;    Taken from `lcourtes@laas.fr--2004-libre',
 ;;;               `skribe-lout--main--0.2--patch-15'.
 ;;;    Based on `latex.skr', copyright 2003, 2004 Manuel Serrano.
+;;;
+;;;    For more information on Lout, see http://lout.sf.net/ .
 
 
 (define-skribe-module (skribilo engine lout)
@@ -518,8 +521,10 @@
   (let ((ident1 (markup-option entry1 :title))
 	(ident2 (markup-option entry2 :title)))
     (if (and (markup? ident1) (markup? ident2))
-	(< (markup-option ident1 'number)
-	   (markup-option ident2 'number))
+        (let ((n1 (markup-option ident1 'number))
+              (n2 (markup-option ident2 'number)))
+          (and (number? n1) (number? n2)
+               (< n1 n2)))
 	(begin
 	  (fprint (current-error-port) "i1: " ident1 ", " entry1)
 	  (fprint (current-error-port) "i2: " ident2 ", " entry2)))))
@@ -2532,7 +2537,7 @@
 		       (output (car rs) e))
 		   (if (pair? (cdr rs))
 		       (begin
-			 (display ",")
+			 (display ", ")
 			 (loop (cdr rs)))))))))
    :after "]")
 
@@ -2591,44 +2596,45 @@
 ;*---------------------------------------------------------------------*/
 (markup-writer '&the-bibliography
    :before (lambda (n e)
-	     ;; Compute the length (in characters) of the longest entry label
-	     ;; so that the label width of the list is adjusted.
-	     (let loop ((entries (markup-body n))
-			(label-width 0))
-	       (if (null? entries)
-		   (begin
-		     (display "\n# the-bibliography\n@LP\n")
-		     ;; usually, the tag with be something like "[7]", hence
-		     ;; the `+ 1' below (`[]' is narrower than 2f)
-		     (printf  "@TaggedList labelwidth { ~af }\n"
-			      (+ 1 label-width)))
-		   (loop (cdr entries)
-			 (let ((entry-length
-				(let liip ((e (car entries)))
-				  (cond
-				   ((markup? e)
-				    (cond ((is-markup? e '&bib-entry)
-					   (liip (markup-option e :title)))
-					  ((is-markup? e '&bib-entry-ident)
-					   (liip (markup-option e 'number)))
-					  (else
-					   (liip (markup-body e)))))
-				   ((string? e)
-				    (string-length e))
-				   ((number? e)
-				    (liip (number->string e)))
-				   ((list? e)
-				    (apply + (map liip e)))
-				   (else 0)))))
-; 			   (fprint (current-error-port)
-; 				   "node=" (car entries)
-; 				   " body=" (markup-body (car entries))
-; 				   " title=" (markup-option (car entries)
-; 							    :title)
-; 				   " len=" entry-length)
-			   (if (> label-width entry-length)
-			       label-width
-			       entry-length))))))
+             (display "\n# the-bibliography\n@LP\n")
+
+             (case (markup-option n 'labels)
+               ((number)
+                ;; Compute the length (in characters) of the longest entry
+                ;; label so that the label width of the list is adjusted.
+                (let loop ((entries (markup-body n))
+                           (label-width 0))
+                  (if (null? entries)
+                      ;; usually, the tag with be something like "[7]", hence
+                      ;; the `+ 1' below (`[]' is narrower than 2f)
+                      (printf  "@TaggedList labelwidth { ~af }\n"
+                               (+ 1 label-width))
+                      (loop (cdr entries)
+                            (let ((entry-length
+                                   (let liip ((e (car entries)))
+                                     (cond
+                                      ((markup? e)
+                                       (cond ((is-markup? e '&bib-entry)
+                                              (liip (markup-option e :title)))
+                                             ((is-markup? e '&bib-entry-ident)
+                                              (liip (markup-option e 'number)))
+                                             (else
+                                              (liip (markup-body e)))))
+                                      ((string? e)
+                                       (string-length e))
+                                      ((number? e)
+                                       (liip (number->string e)))
+                                      ((list? e)
+                                       (apply + (map liip e)))
+                                      (else 0)))))
+
+                              (if (> label-width entry-length)
+                                  label-width
+                                  entry-length))))))
+
+               (else  ;; `name+year' and others.
+                (display "@TaggedList\n"))))
+
    :after (lambda (n e)
 	     (display "\n@EndList # the-bibliography (end)\n")))
 
@@ -2637,13 +2643,25 @@
 ;*---------------------------------------------------------------------*/
 (markup-writer '&bib-entry
    :options '(:title)
-   :before "@TagItem "
+
+   :before (lambda (n e)
+             (let ((ident (markup-option n :title)))
+               (if (is-markup? ident '&bib-entry-ident)
+                   (let ((number (markup-option ident 'number)))
+                     (cond ((number? number)
+                            (display "@TagItem "))
+                           (else
+                            ;; probably `name+year'-style.
+                            (display "@DropTagItem "))))
+                   (display "@TagItem "))))
+
    :action (lambda (n e)
 	     (display " { ")
 	     (output n e (markup-writer-get '&bib-entry-label e))
 	     (display " }  { ")
 	     (output n e (markup-writer-get '&bib-entry-body e))
 	     (display " }"))
+
    :after "\n")
 
 ;*---------------------------------------------------------------------*/