From 62443764135d6810a8e45d888b282344c5de42a5 Mon Sep 17 00:00:00 2001 From: Ludovic Court`es Date: Fri, 17 Nov 2006 09:05:31 +0000 Subject: Lout engine: Better cover sheet for `doc' documents. * src/guile/skribilo/engine/lout.scm (lout-make-doc-cover-sheet): Improved spacing. Moved `date-line' after `author'. Provide a default value for `date-line' when it's `#t'. git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-15 --- src/guile/skribilo/engine/lout.scm | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/guile') diff --git a/src/guile/skribilo/engine/lout.scm b/src/guile/skribilo/engine/lout.scm index 92977e7..db93257 100644 --- a/src/guile/skribilo/engine/lout.scm +++ b/src/guile/skribilo/engine/lout.scm @@ -432,18 +432,22 @@ (output title engine) (display "The Lout Document")) (display " }\n") - (display "//1.7fx\n") - (if date-line - (begin - (display "@Center { ") - (output date-line engine) - (display " }\n//1.4fx\n"))) + (display "//2.0fx\n") (if author (begin (display "@Center { ") (output author engine) (display " }\n") - (display "//4fx\n"))) + (display "//4.6fx\n"))) + (if date-line + (begin + (display "@Center { ") + (output (if (eq? #t date-line) + (strftime "%e %B %Y" (localtime (current-time))) + date-line) + engine) + (display " }\n//1.7fx\n"))) + (display "//0.5fx\n") (if multi-column? (display "\n} # @FullWidth\n")))) -- cgit v1.2.3 From b2aec83973f1b7c2bf9e952ed8e713611cbdc7fb Mon Sep 17 00:00:00 2001 From: Ludovic Court`es Date: Fri, 17 Nov 2006 09:06:30 +0000 Subject: outline reader: Support keywords. * src/guile/skribilo/reader/outline.scm (outline-reader)[keywords-rx]: New. [author-rx]: Support "Authors" (plural). [extract-keywords]: New. Use a `cond' instead of nested `if's when matching the title/author/keywords regexps. git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-16 --- src/guile/skribilo/reader/outline.scm | 54 +++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 15 deletions(-) (limited to 'src/guile') diff --git a/src/guile/skribilo/reader/outline.scm b/src/guile/skribilo/reader/outline.scm index 09792f5..7411892 100644 --- a/src/guile/skribilo/reader/outline.scm +++ b/src/guile/skribilo/reader/outline.scm @@ -22,7 +22,10 @@ :use-module (skribilo utils syntax) :use-module (skribilo reader) :use-module (ice-9 optargs) + :use-module (srfi srfi-11) + :use-module (srfi srfi-13) + :use-module (srfi srfi-14) :autoload (ice-9 rdelim) (read-line) :autoload (ice-9 regex) (make-regexp) @@ -380,12 +383,19 @@ to @var{node-type}." (define modeline-rx (make-regexp "^[[:space:]]*-\\*- [a-zA-Z-]+ -\\*-[[:space:]]*$")) (define title-rx (make-regexp "^[Tt]itle: (.+)$" regexp/extended)) - (define author-rx (make-regexp "^[Aa]uthor: (.+)$" regexp/extended)) + (define author-rx (make-regexp "^[Aa]uthors?: (.+)$" regexp/extended)) + (define keywords-rx + (make-regexp "^[Kk]ey ?[wW]ords?: (.+)$" regexp/extended)) + + (define (extract-keywords str) + (map string-trim-both + (string-tokenize str (char-set-complement (char-set #\,))))) (let ((doc-proc (make-document-processor %node-processors %line-processor))) (let loop ((title #f) (author #f) + (keywords '()) (line (read-line port))) (if (eof-object? line) @@ -394,20 +404,34 @@ to @var{node-type}." line) (if (or (empty-line? line) (regexp-exec modeline-rx line)) - (loop title author (read-line port)) - (let ((title-match (regexp-exec title-rx line))) - (if title-match - (loop (match:substring title-match 1) - author (read-line port)) - (let ((author-match (regexp-exec author-rx line))) - (if author-match - (loop title (match:substring author-match 1) - (read-line port)) - - ;; Let's go. - `(document :title ,title - :author (author :name ,author) - ,@(doc-proc line port))))))))))) + (loop title author keywords (read-line port)) + (cond ((regexp-exec title-rx line) + => + (lambda (title-match) + (loop (match:substring title-match 1) + author keywords (read-line port)))) + + ((regexp-exec author-rx line) + => + (lambda (author-match) + (loop title (match:substring author-match 1) + keywords (read-line port)))) + + ((regexp-exec keywords-rx line) + => + (lambda (kw-match) + (loop title author + (append keywords + (extract-keywords + (match:substring kw-match 1))) + (read-line port)))) + + (else + ;; Let's go. + `(document :title ,title + :author (author :name ,author) + :keywords ',keywords + ,@(doc-proc line port))))))))) (define* (make-outline-reader :optional (version "0.1")) -- cgit v1.2.3 From a5b8c2cfaf31b5d81a900b1020eb45252d775dd0 Mon Sep 17 00:00:00 2001 From: Ludovic Courtes Date: Sat, 25 Nov 2006 17:37:51 +0000 Subject: lout: bib-ref+: Gracefully handle `unref' objects. * src/guile/skribilo/engine/lout.scm (bib-ref+)[canonicalize-entry]: Handle `unref' objects. [help-proc]: Don't pass `unref' objects to PROC. git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-17 --- src/guile/skribilo/engine/lout.scm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/guile') diff --git a/src/guile/skribilo/engine/lout.scm b/src/guile/skribilo/engine/lout.scm index db93257..272b131 100644 --- a/src/guile/skribilo/engine/lout.scm +++ b/src/guile/skribilo/engine/lout.scm @@ -2495,6 +2495,7 @@ ((is-markup? x 'bib-entry) x) ((is-markup? x 'bib-ref) (handle-ast (markup-body x))) + ((is-markup? x 'unref) #f) (else (skribe-error 'lout @@ -2502,9 +2503,14 @@ x))))) (help-proc (lambda (proc) (lambda (e1 e2) - (proc (canonicalize-entry e1) - (canonicalize-entry e2))))) + (let ((e1 (canonicalize-entry e1)) + (e2 (canonicalize-entry e2))) + ;; don't pass `unref's to PROC + (if (and e1 e2) + (proc e1 e2) + #f))))) (sort-proc (engine-custom e 'bib-refs-sort-proc))) + (let loop ((rs (if sort-proc (sort entries (help-proc sort-proc)) entries))) -- cgit v1.2.3 From 45b606578f7bae67ee92ca77b894d71a3ebab82a Mon Sep 17 00:00:00 2001 From: Ludovic Courtes Date: Sat, 25 Nov 2006 17:40:28 +0000 Subject: Introduced `markup-number-string'. * src/guile/skribilo/ast.scm: Use `(ice-9 optargs)'. (markup-number-string): New (stolen from the Lout engine). * src/guile/skribilo/engine/lout.scm: Use it. (lout-structure-number-string): Redefined in terms of `markup-number-string'. git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-18 --- src/guile/skribilo/ast.scm | 22 ++++++++++++++++++++++ src/guile/skribilo/engine/lout.scm | 22 ++++++++-------------- 2 files changed, 30 insertions(+), 14 deletions(-) (limited to 'src/guile') diff --git a/src/guile/skribilo/ast.scm b/src/guile/skribilo/ast.scm index 542f629..55f37bf 100644 --- a/src/guile/skribilo/ast.scm +++ b/src/guile/skribilo/ast.scm @@ -30,6 +30,9 @@ :autoload (skribilo location) (location?) :autoload (srfi srfi-1) (fold) + + :use-module (ice-9 optargs) + :export ( ast? ast-loc ast-loc-set! ast-parent ast->string ast->file-location ast-resolved? @@ -62,6 +65,9 @@ find-up find1-up ast-document ast-chapter ast-section + ;; numbering + markup-number-string + ;; error conditions &ast-error &ast-orphan-error &ast-cycle-error &markup-unknown-option-error &markup-already-bound-error @@ -596,6 +602,22 @@ (define (ast-section m) (find1-up (lambda (n) (is-markup? n 'section)) m)) + +;;; +;;; Section numbering. +;;; + +(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) "")))))) + ;;; arch-tag: e2489bd6-1b6d-4b03-bdfb-83cffd2f7ce7 diff --git a/src/guile/skribilo/engine/lout.scm b/src/guile/skribilo/engine/lout.scm index 272b131..6106f35 100644 --- a/src/guile/skribilo/engine/lout.scm +++ b/src/guile/skribilo/engine/lout.scm @@ -502,7 +502,7 @@ (if num (begin (if (is-markup? node 'chapter) (display "@B { ")) - (printf "~a. |2s " (lout-structure-number-string node)) + (printf "~a. |2s " (markup-number-string node)) (output title engine) (if (is-markup? node 'chapter) (display " }"))) (if (is-markup? node 'chapter) @@ -525,7 +525,7 @@ (define (lout-pdf-bookmark-title node engine) ;; Default implementation of the `pdf-bookmark-title-proc' custom that ;; returns a title (a string) for the PDF bookmark of `node'. - (let ((number (lout-structure-number-string node))) + (let ((number (markup-number-string node))) (string-append (if (string=? number "") "" (string-append number ". ")) (ast->string (markup-option node :title))))) @@ -1321,17 +1321,11 @@ doc-type))))) (define-public (lout-structure-number-string markup) - ;; Return a structure number string such as "1.2". - ;; FIXME: External code has started to rely on this. This should be - ;; generalized and moved elsewhere. - (let loop ((struct markup)) - (if (document? struct) - "" - (let ((parent-num (loop (ast-parent struct))) - (num (markup-option struct :number))) - (string-append parent-num - (if (string=? "" parent-num) "" ".") - (if (number? num) (number->string num) "")))))) + ;; FIXME: External code has started to rely on this before this was moved + ;; to the `ast' module as `markup-number-string'. Thus, we'll have to keep it + ;; here for some time. + (markup-number-string markup ".")) + ;*---------------------------------------------------------------------*/ ;* lout-block-before ... */ @@ -1360,7 +1354,7 @@ (if (number? number) (printf " @BypassNumber { ~a }\n" - (lout-structure-number-string n)) + (markup-number-string n)) (if (not number) ;; this trick hides the section number (printf " @BypassNumber { } # unnumbered\n"))) -- cgit v1.2.3 From 2415df2ae4716bec5ca0d9605116c43d0977ea30 Mon Sep 17 00:00:00 2001 From: Ludovic Courtes Date: Sat, 25 Nov 2006 17:41:04 +0000 Subject: `base' package: Added `numref'. * src/guile/skribilo/package/base.scm (numref): New. git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-19 --- src/guile/skribilo/package/base.scm | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/guile') diff --git a/src/guile/skribilo/package/base.scm b/src/guile/skribilo/package/base.scm index bbb2a62..4c9e84c 100644 --- a/src/guile/skribilo/package/base.scm +++ b/src/guile/skribilo/package/base.scm @@ -1187,6 +1187,49 @@ (line (line-ref line)) (else (skribe-error 'ref "illegal reference" opts))))) + +;*---------------------------------------------------------------------*/ +;* numref ... */ +;*---------------------------------------------------------------------*/ +(define-markup (numref #!rest opts + #!key (ident #f) (text "") (page #f) + (separator ".") (class #f)) + ;; Produce a numbered reference to `ident'. + (new unresolved + (proc (lambda (n e env) + (let* ((parent (ast-parent n)) + (doc (ast-document n)) + (target (document-lookup-node doc ident)) + (number (and target + (markup-option target :number)))) + (cond + ((not target) + (skribe-warning/ast 1 n 'numref + (format #f "can't find `ident': ") + ident) + (new markup + (markup 'unref) + (ident (symbol->string (gensym "unref"))) + (class class) + (required-options '(:text)) + (options `((kind numref) + ,@(the-options opts :ident :class))) + (body (list ident ": " (ast->file-location n))))) + ((unresolved? number) + ;; Loop until `number' is resolved. + n) + (else + (let ((xref + (ref :text + (list (if text text "") " " + (if (number? number) + (markup-number-string target + separator) + "")) + :page page + :handle (handle target)))) + (resolve! xref e env))))))))) + ;*---------------------------------------------------------------------*/ ;* resolve ... */ ;*---------------------------------------------------------------------*/ -- cgit v1.2.3 From 80b757fc4bf93f59edde426b9fca4dcca15509c3 Mon Sep 17 00:00:00 2001 From: Ludovic Courtes Date: Sat, 25 Nov 2006 17:42:18 +0000 Subject: Cleaned up `(skribilo biblio)' a bit. * doc/user/bib.skb: Replaced `default-bib-table' with `*bib-table*'. * src/guile/skribilo/biblio.scm: Clean up. (skribe-open-bib-file): Renamed to `open-bib-file'. * src/guile/skribilo/package/base.scm: Use `*bib-table*' instead of `default-bib-table'. * src/guile/skribilo/utils/compat.scm: Autoload `biblio'. (default-bib-table): New. (skribe-open-bib-file): New. git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-21 --- doc/user/bib.skb | 20 ++++--- src/guile/skribilo/biblio.scm | 103 +++++++++++++----------------------- src/guile/skribilo/package/base.scm | 8 +-- src/guile/skribilo/utils/compat.scm | 13 +++++ 4 files changed, 67 insertions(+), 77 deletions(-) (limited to 'src/guile') diff --git a/doc/user/bib.skb b/doc/user/bib.skb index 5b26417..e7b5b77 100644 --- a/doc/user/bib.skb +++ b/doc/user/bib.skb @@ -52,32 +52,36 @@ tables.]) (p [The predicate ,(code "bib-table?") returns ,(code "#t") if and only if its argument is a bibliography table as returned by -,(markup-ref "make-bib-table") or ,(markup-ref "default-bib-table"). Otherwise +,(markup-ref "make-bib-table") or ,(markup-ref "*bib-table*"). Otherwise ,(code "bib-table?") returns ,(code "#f").]) (doc-markup 'bib-table? '((obj [The value to be tested])) - :see-also '(make-bib-table default-bib-table bibliography the-bibliography) + :see-also '(make-bib-table *bib-table* bibliography the-bibliography) :force-engines *api-engines* :common-args '() :source #f ;;"skribilo/biblio.scm" :def '(define-markup (bib-table? obj) ...)) - (p [The function ,(code "default-bib-table") returns a global, pre-existing + (p [The function ,(code "*bib-table*") returns a global, pre-existing bibliography-table:]) - (doc-markup 'default-bib-table + (doc-markup '*bib-table* '() :see-also '(bib-table? make-bib-table bibliography the-bibliography) :force-engines *api-engines* :common-args '() :source #f - :def '(define-markup (default-bib-table) ...)) + :def '(define-markup (*bib-table*) ...)) + (p [Technically, ,(code "*bib-table*") is actually an ,(ref :text +[SRFI-39] :url "http://srfi.schemers.org/srfi-39/srfi-39.html") +parameter object, so it can be queried and modified like any other +parameter object.]) (p [The function ,(code "make-bib-table") constructs a new bibliography-table:]) (doc-markup 'make-bib-table '((ident [The name of the bibliography table.])) - :see-also '(bib-table? default-bib-table bibliography the-bibliography) + :see-also '(bib-table? *bib-table* bibliography the-bibliography) :force-engines *api-engines* :common-args '() :source #f @@ -109,7 +113,7 @@ the ,(code "bibliography") Skribe function call before the call to the :text "bibliograph path")). Otherwise, it is a list described by the ,(ref :subsection "Bibliography syntax" :text "syntax") below.])) - :see-also '(bib-table? make-bib-table default-bib-table the-bibliography) + :see-also '(bib-table? make-bib-table *bib-table* the-bibliography) :force-engines *api-engines* :common-args '()) @@ -161,7 +165,7 @@ Here is an example of a simple Skribe database.]) filtered in by ,(param :pred). The value ,(code "full") tells Skribe to count all entries, event those filtered out by ,(param :pred).])) - :see-also '(bib-table? make-bib-table default-bib-table bibliography) + :see-also '(bib-table? make-bib-table *bib-table* bibliography) :force-engines *api-engines* :common-args '()) diff --git a/src/guile/skribilo/biblio.scm b/src/guile/skribilo/biblio.scm index 1fb4b78..55f2ea9 100644 --- a/src/guile/skribilo/biblio.scm +++ b/src/guile/skribilo/biblio.scm @@ -1,5 +1,6 @@ ;;; biblio.scm -- Bibliography functions. ;;; +;;; Copyright 2001, 2002, 2003, 2004 Manuel Serrano ;;; Copyright 2003, 2004 Erick Gallesio - I3S-CNRS/ESSI ;;; Copyright 2005, 2006 Ludovic Courtès ;;; @@ -24,9 +25,10 @@ :use-module (skribilo utils strings) :use-module (skribilo utils syntax) ;; `when', `unless' + :use-module (srfi srfi-1) :autoload (srfi srfi-34) (raise) :use-module (srfi srfi-35) - :use-module (srfi srfi-1) + :use-module (srfi srfi-39) :autoload (skribilo condition) (&file-search-error) :autoload (skribilo reader) (%default-reader) @@ -36,9 +38,9 @@ :use-module (ice-9 optargs) :use-module (oop goops) - :export (bib-table? make-bib-table default-bib-table + :export (bib-table? make-bib-table *bib-table* bib-add! bib-duplicate bib-for-each bib-map - skribe-open-bib-file parse-bib + open-bib-file parse-bib bib-load! resolve-bib resolve-the-bib make-bib-entry @@ -52,27 +54,15 @@ ;;; Provides the bibliography data type and basic bibliography handling, ;;; including simple procedures to sort bibliography entries. ;;; -;;; FIXME: This module need cleanup! -;;; ;;; Code: (fluid-set! current-reader %skribilo-module-reader) - -;; FIXME: Should be a fluid? -(define *bib-table* #f) - -;; Forward declarations -(define skribe-open-bib-file #f) -(define parse-bib #f) - -;;; ====================================================================== ;;; -;;; Utilities +;;; Accessors. ;;; -;;; ====================================================================== (define (make-bib-table ident) (make-hash-table)) @@ -80,10 +70,9 @@ (define (bib-table? obj) (hash-table? obj)) -(define (default-bib-table) - (unless *bib-table* - (set! *bib-table* (make-bib-table "default-bib-table"))) - *bib-table*) +;; The current bib table. +(define *bib-table* + (make-parameter (make-bib-table "default-bib-table"))) (define (%bib-error who entry) (let ((msg "bibliography syntax error on entry")) @@ -91,22 +80,34 @@ (skribe-line-error (%epair-file entry) (%epair-line entry) who msg entry) (skribe-error who msg entry)))) -(define* (bib-for-each proc :optional (table (default-bib-table))) +(define (bib-add! table . entries) + (if (not (bib-table? table)) + (skribe-error 'bib-add! "Illegal bibliography table" table) + (for-each (lambda (entry) + (cond + ((and (list? entry) (> (length entry) 2)) + (let* ((kind (car entry)) + (key (format #f "~A" (cadr entry))) + (fields (cddr entry)) + (old (hash-ref table key))) + (if old + (bib-duplicate key #f old) + (hash-set! table key + (make-bib-entry kind key fields #f))))) + (else + (%bib-error 'bib-add! entry)))) + entries))) + +(define* (bib-for-each proc :optional (table (*bib-table*))) (hash-for-each (lambda (ident entry) (proc ident entry)) table)) -(define* (bib-map proc :optional (table (default-bib-table))) +(define* (bib-map proc :optional (table (*bib-table*))) (hash-map->list (lambda (ident entry) (proc ident entry)) table)) - -;;; ====================================================================== -;;; -;;; BIB-DUPLICATE -;;; -;;; ====================================================================== (define (bib-duplicate ident from old) (let ((ofrom (markup-option old 'from))) (skribe-warning 2 @@ -120,11 +121,11 @@ " ignoring redefinition.")))) -;;; ====================================================================== + ;;; -;;; PARSE-BIB +;;; Parsing. ;;; -;;; ====================================================================== + (define (parse-bib table port) (let ((read %default-reader)) ;; FIXME: We should use a fluid (if (not (bib-table? table)) @@ -146,43 +147,15 @@ (else (%bib-error 'bib-parse entry))))))))) - -;;; ====================================================================== -;;; -;;; BIB-ADD! -;;; -;;; ====================================================================== -(define (bib-add! table . entries) - (if (not (bib-table? table)) - (skribe-error 'bib-add! "Illegal bibliography table" table) - (for-each (lambda (entry) - (cond - ((and (list? entry) (> (length entry) 2)) - (let* ((kind (car entry)) - (key (format #f "~A" (cadr entry))) - (fields (cddr entry)) - (old (hash-ref table key))) - (if old - (bib-duplicate key #f old) - (hash-set! table key - (make-bib-entry kind key fields #f))))) - (else - (%bib-error 'bib-add! entry)))) - entries))) - - -;;; ====================================================================== -;;; -;;; SKRIBE-OPEN-BIB-FILE -;;; -;;; ====================================================================== -;; FIXME: Factoriser -(define (skribe-open-bib-file file command) +(define* (open-bib-file file :optional (command #f)) (let ((path (search-path (*bib-path*) file))) (if (string? path) (begin (when (> (*verbose*) 0) - (format (current-error-port) " [loading bibliography: ~S]\n" path)) + (format (current-error-port) + " [loading bibliography: ~S]\n" path)) + ;; FIXME: The following `open-input-file' won't work with actual + ;; commands. We need to use `(ice-9 popen)'. (open-input-file (if (string? command) (string-append "| " (format #f command path)) @@ -209,7 +182,7 @@ (if (not (bib-table? table)) (skribe-error 'bib-load "Illegal bibliography table" table) ;; read the file - (let ((p (skribe-open-bib-file filename command))) + (let ((p (open-bib-file filename command))) (if (not (input-port? p)) (skribe-error 'bib-load "Can't open data base" filename) (unwind-protect diff --git a/src/guile/skribilo/package/base.scm b/src/guile/skribilo/package/base.scm index 4c9e84c..01e8667 100644 --- a/src/guile/skribilo/package/base.scm +++ b/src/guile/skribilo/package/base.scm @@ -33,7 +33,7 @@ :autoload (skribilo engine) (engine?) ;; optional ``sub-packages'' - :autoload (skribilo biblio) (default-bib-table resolve-bib + :autoload (skribilo biblio) (*bib-table* resolve-bib bib-load! bib-add!) :autoload (skribilo color) (skribe-use-color!) :autoload (skribilo source) (language? source-read-lines source-fontify) @@ -1015,7 +1015,7 @@ (subsection #f) (subsubsection #f) (bib #f) - (bib-table (default-bib-table)) + (bib-table (*bib-table*)) (url #f) (figure #f) (mark #f) @@ -1245,7 +1245,7 @@ ;*---------------------------------------------------------------------*/ (define-markup (bibliography #!rest files #!key - (command #f) (bib-table (default-bib-table))) + (command #f) (bib-table (*bib-table*))) (for-each (lambda (f) (cond ((string? f) @@ -1267,7 +1267,7 @@ (define-markup (the-bibliography #!rest opts #!key pred - (bib-table (default-bib-table)) + (bib-table (*bib-table*)) (sort bib-sort/authors) (count 'partial)) (if (not (memq count '(partial full))) diff --git a/src/guile/skribilo/utils/compat.scm b/src/guile/skribilo/utils/compat.scm index 118f294..4905cef 100644 --- a/src/guile/skribilo/utils/compat.scm +++ b/src/guile/skribilo/utils/compat.scm @@ -35,6 +35,7 @@ :autoload (skribilo lib) (type-name) :autoload (skribilo resolve) (*document-being-resolved*) :autoload (skribilo output) (*document-being-output*) + :autoload (skribilo biblio) (*bib-table* open-bib-file) :use-module (skribilo debug) :re-export (file-size) ;; re-exported from `(skribilo utils files)' @@ -207,6 +208,18 @@ (or (find-markups ident) '())) + +;;; +;;; Bibliography. +;;; + +(define-public (default-bib-table) + (*bib-table*)) + +(define-public (skribe-open-bib-file file command) + (open-bib-file file command)) + + ;;; ;;; Debugging facilities. -- cgit v1.2.3 From 81f9b6cae9be169cf0723434dc629d75a37595a7 Mon Sep 17 00:00:00 2001 From: Ludovic Courtes Date: Sat, 2 Dec 2006 10:40:47 +0000 Subject: eq: Added the `:div-style' option. * src/guile/skribilo/package/eq.scm (eq): New `:div-style' option. Return a container rather than a markup. (eq:/): Added support for `:div-style'. * src/guile/skribilo/package/eq/lout.scm (eq): List `:div-style' as supported. (div-style->lout): New. (simple-lout-markup-writer): Handle LOUT-NAME as procedure. (eq:/): Use the `:div-style' option. (eq:script): Only use "on" when SUP is passed. git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-22 --- src/guile/skribilo/package/eq.scm | 22 +++++++-- src/guile/skribilo/package/eq/lout.scm | 89 +++++++++++++++++++++------------- 2 files changed, 72 insertions(+), 39 deletions(-) (limited to 'src/guile') diff --git a/src/guile/skribilo/package/eq.scm b/src/guile/skribilo/package/eq.scm index 4f5020e..58fb77c 100644 --- a/src/guile/skribilo/package/eq.scm +++ b/src/guile/skribilo/package/eq.scm @@ -169,12 +169,15 @@ a symbol representing the mathematical operator denoted by @var{m} (e.g., ;;; Markup. ;;; -(define-markup (eq :rest opts :key (ident #f) (inline? #f) - (renderer #f) (class "eq")) - (new markup +(define-markup (eq :rest opts :key (ident #f) (class "eq") + (inline? #f) + (renderer #f) (div-style 'over)) + (new container (markup 'eq) (ident (or ident (symbol->string (gensym "eq")))) - (options (the-options opts)) + (class class) + (options `((:div-style ,div-style) + ,@(the-options opts :ident :class :div-style))) (body (let loop ((body (the-body opts)) (result '())) (if (null? body) @@ -187,7 +190,16 @@ a symbol representing the mathematical operator denoted by @var{m} (e.g., ;; passed )))))) -(define-simple-markup eq:/) +(define-markup (eq:/ :rest opts :key (ident #f) (div-style #f)) + ;; If no `:div-style' is specified here, obey the top-level one. + (new markup + (markup 'eq:/) + (ident (or ident (symbol->string (gensym "eq:/")))) + (class #f) + (options `((:div-style ,div-style) + ,@(the-options opts :ident :class :div-style))) + (body (the-body opts)))) + (define-simple-markup eq:*) (define-simple-markup eq:+) (define-simple-markup eq:-) diff --git a/src/guile/skribilo/package/eq/lout.scm b/src/guile/skribilo/package/eq/lout.scm index c487b85..cce5124 100644 --- a/src/guile/skribilo/package/eq/lout.scm +++ b/src/guile/skribilo/package/eq/lout.scm @@ -53,7 +53,7 @@ (markup-writer 'eq (find-engine 'lout) - :options '(:inline?) + :options '(:inline? :div-style) :before "{ " :action (lambda (node engine) (display (if (markup-option node :inline?) @@ -65,6 +65,14 @@ :after " } }") +(define (div-style->lout style) + (case style + ((over) "over") + ((fraction) "frac") + ((div) "div") + ((slash) "slash") + (else + (error "unsupported div style" style)))) (define-macro (simple-lout-markup-writer sym . args) (let* ((lout-name (if (null? args) @@ -83,37 +91,41 @@ `(markup-writer ',(symbol-append 'eq: sym) (find-engine 'lout) :action (lambda (node engine) - (let loop ((operands (markup-body node))) - (if (null? operands) - #t - (let* ((op (car operands)) - (eq-op? (equation-markup? op)) - (need-paren? - (and eq-op? - (< (operator-precedence - (equation-markup-name->operator - (markup-markup op))) - ,precedence))) - (column (port-column - (current-output-port)))) - - ;; Work around Lout's limitations... - (if (> column 1000) (display "\n")) - - (display (string-append " { " - ,(if parentheses? - open-par - ""))) - (output op engine) - (display (string-append ,(if parentheses? - close-par - "") - " }")) - (if (pair? (cdr operands)) - (display ,(string-append " " - lout-name - " "))) - (loop (cdr operands))))))))) + (let ((lout-name ,(if (string? lout-name) + lout-name + `(,lout-name node + engine)))) + (let loop ((operands (markup-body node))) + (if (null? operands) + #t + (let* ((op (car operands)) + (eq-op? (equation-markup? op)) + (need-paren? + (and eq-op? + (< (operator-precedence + (equation-markup-name->operator + (markup-markup op))) + ,precedence))) + (column (port-column + (current-output-port)))) + + ;; Work around Lout's limitations... + (if (> column 1000) (display "\n")) + + (display (string-append " { " + ,(if parentheses? + open-par + ""))) + (output op engine) + (display (string-append ,(if parentheses? + close-par + "") + " }")) + (if (pair? (cdr operands)) + (display (string-append " " + lout-name + " "))) + (loop (cdr operands)))))))))) ;; `+' and `*' have higher precedence than `-', `/', `=', etc., so their @@ -124,7 +136,16 @@ (simple-lout-markup-writer +) (simple-lout-markup-writer * "times") (simple-lout-markup-writer - "-") -(simple-lout-markup-writer / "over" #f) +(simple-lout-markup-writer / + (lambda (n e) + ;; Obey either the per-node `:div-style' or the + ;; top-level one. + (or (markup-option n :div-style) + (let* ((eq (ast-parent n)) + (div-style + (markup-option eq :div-style))) + (div-style->lout div-style)))) + #f) (simple-lout-markup-writer =) (simple-lout-markup-writer <) (simple-lout-markup-writer >) @@ -208,7 +229,7 @@ (display " } "))) (if sub (begin - (display " on { ") + (display (if sup " on { " " sub { ")) (output sub engine) (display " } "))) (display " } ")))) -- cgit v1.2.3 From 32136d000be5c570133c48c3650d5d7b51efa2fc Mon Sep 17 00:00:00 2001 From: Ludovic Courtes Date: Sat, 2 Dec 2006 10:42:56 +0000 Subject: eq: Added `limit' and `combinations'. * src/guile/skribilo/package/eq.scm (%operators): Added `limit' and `combinations'. (eq:limit): New. (eq:combinations): New. (eq:limit): New text-based writer. (eq:combinations): Likewise. * src/guile/skribilo/package/eq/lout.scm (eq:limit): New. (eq:combinations): New. git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-24 --- src/guile/skribilo/package/eq.scm | 40 +++++++++++++++++++++++++++++++++- src/guile/skribilo/package/eq/lout.scm | 24 ++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) (limited to 'src/guile') diff --git a/src/guile/skribilo/package/eq.scm b/src/guile/skribilo/package/eq.scm index 58fb77c..c45f698 100644 --- a/src/guile/skribilo/package/eq.scm +++ b/src/guile/skribilo/package/eq.scm @@ -54,7 +54,7 @@ (define %operators '(/ * + - = != ~= < > <= >= sqrt expt sum product script - in notin apply)) + in notin apply limit combinations)) (define %symbols ;; A set of symbols that are automatically recognized within an `eq' quoted @@ -264,6 +264,22 @@ a symbol representing the mathematical operator denoted by @var{m} (e.g., (loop (cdr body) (cons first result))))))))) +(define-markup (eq:limit var lim :rest body :key (ident #f)) + (new markup + (markup 'eq:limit) + (ident (or ident (symbol->string (gensym "eq:limit")))) + (options `((:var ,var) (:limit ,lim) + ,@(the-options body :ident))) + (body (the-body body)))) + +(define-markup (eq:combinations x y :rest opts :key (ident #f)) + (new markup + (markup 'eq:combinations) + (ident (or ident (symbol->string (gensym "eq:combinations")))) + (options `((:of ,x) (:among ,y) + ,@(the-options opts :ident))) + (body (the-body opts)))) + ;;; ;;; Text-based rendering. @@ -434,6 +450,28 @@ a symbol representing the mathematical operator denoted by @var{m} (e.g., (output (sup sup*) engine) (output (sub sub*) engine)))) +(markup-writer 'eq:limit (find-engine 'base) + :action (lambda (node engine) + (let ((body (markup-body node)) + (var (markup-option node :var)) + (limit (markup-option node :limit))) + (display "lim (") + (output var engine) + (output (symbol "->") engine) + (output limit engine) + (display ", ") + (output body engine) + (display ")")))) + +(markup-writer 'eq:combinations (find-engine 'base) + :action (lambda (node engine) + (let ((of (markup-option node :of)) + (among (markup-option node :among))) + (display "combinations(") + (output of engine) + (display ", ") + (output among engine) + (display ")")))) diff --git a/src/guile/skribilo/package/eq/lout.scm b/src/guile/skribilo/package/eq/lout.scm index cce5124..563fdbf 100644 --- a/src/guile/skribilo/package/eq/lout.scm +++ b/src/guile/skribilo/package/eq/lout.scm @@ -191,6 +191,30 @@ (display ")")))) +(markup-writer 'eq:limit (find-engine 'lout) + :action (lambda (node engine) + (let ((body (markup-body node)) + (var (markup-option node :var)) + (limit (markup-option node :limit))) + (display "{ lim on { ") + (output var engine) + (display " --> ") + (output limit engine) + (display " } } (") + (output body engine) + (display ") ")))) + +(markup-writer 'eq:combinations (find-engine 'lout) + :action (lambda (node engine) + (let ((of (markup-option node :of)) + (among (markup-option node :among))) + (display " { matrix atleft { blpar } atright { brpar } { ") + (display "row col { ") + (output among engine) + (display " } row col { ") + (output of engine) + (display " } } }\n")))) + ;;; ;;; Sums, products, integrals, etc. -- cgit v1.2.3 From a7a4342d6efd74f7231994b4cc5b4255b36e13f4 Mon Sep 17 00:00:00 2001 From: Ludovic Courtes Date: Sat, 2 Dec 2006 10:43:59 +0000 Subject: eq: Properly handle operator precedence. * src/guile/skribilo/package/eq.scm (%operator-precedence): Fixed according to Wikipedia. (simple-markup-writer): Honor operator precedence. * src/guile/skribilo/package/eq/lout.scm (simple-lout-markup-writer): Likewise. git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-25 --- src/guile/skribilo/package/eq.scm | 39 +++++++++++++++++++++------------- src/guile/skribilo/package/eq/lout.scm | 28 ++++++++++++------------ 2 files changed, 38 insertions(+), 29 deletions(-) (limited to 'src/guile') diff --git a/src/guile/skribilo/package/eq.scm b/src/guile/skribilo/package/eq.scm index c45f698..a3eb99c 100644 --- a/src/guile/skribilo/package/eq.scm +++ b/src/guile/skribilo/package/eq.scm @@ -116,18 +116,27 @@ a symbol representing the mathematical operator denoted by @var{m} (e.g., ;;; (define %operator-precedence - ;; FIXME: This needs to be augmented. - '((+ . 1) - (- . 1) - (* . 2) - (/ . 2) - (sum . 3) + ;; Taken from http://en.wikipedia.org/wiki/Order_of_operations . + '((expt . 2) + (sqrt . 2) + + (* . 3) + (/ . 3) (product . 3) - (= . 0) - (< . 0) - (> . 0) - (<= . 0) - (>= . 0))) + + (+ . 4) + (- . 4) + (sum . 4) + + (< . 6) + (> . 6) + (<= . 6) + (>= . 6) + + (= . 7) + (!= . 7) + (~= . 7))) + (define-public (operator-precedence op) (let ((p (assq op %operator-precedence))) @@ -329,10 +338,10 @@ a symbol representing the mathematical operator denoted by @var{m} (e.g., (nested-eq? (equation-markup? o)) (need-paren? (and nested-eq? -; (< (operator-precedence -; (equation-markup-name->operator -; (markup-markup o))) -; ,precedence) + (>= (operator-precedence + (equation-markup-name->operator + (markup-markup o))) + ,precedence) ) )) diff --git a/src/guile/skribilo/package/eq/lout.scm b/src/guile/skribilo/package/eq/lout.scm index 563fdbf..9cd594b 100644 --- a/src/guile/skribilo/package/eq/lout.scm +++ b/src/guile/skribilo/package/eq/lout.scm @@ -85,8 +85,12 @@ ;; Note: We could use `pmatrix' here but it precludes line-breaking ;; within equations. - (open-par `(if need-paren? "{ @VScale ( }" "")) - (close-par `(if need-paren? "{ @VScale ) }" ""))) + (open-par (if parentheses? + `(if need-paren? "{ @VScale ( }" "") + "")) + (close-par (if parentheses? + `(if need-paren? "{ @VScale ) }" "") + ""))) `(markup-writer ',(symbol-append 'eq: sym) (find-engine 'lout) @@ -102,25 +106,21 @@ (eq-op? (equation-markup? op)) (need-paren? (and eq-op? - (< (operator-precedence - (equation-markup-name->operator - (markup-markup op))) - ,precedence))) + (>= (operator-precedence + (equation-markup-name->operator + (markup-markup op))) + ,precedence))) (column (port-column (current-output-port)))) ;; Work around Lout's limitations... (if (> column 1000) (display "\n")) - (display (string-append " { " - ,(if parentheses? - open-par - ""))) + (display + (string-append " { " ,open-par)) (output op engine) - (display (string-append ,(if parentheses? - close-par - "") - " }")) + (display + (string-append ,close-par " }")) (if (pair? (cdr operands)) (display (string-append " " lout-name -- cgit v1.2.3 From 362047ce067c665d7f7e63de362a9e9f5dd50dbf Mon Sep 17 00:00:00 2001 From: Ludovic Courtes Date: Sat, 2 Dec 2006 10:44:57 +0000 Subject: eq: Added `eq-display' and the `:align-with' option for `eq'. * src/guile/skribilo/package/eq.scm: Use `srfi-39'. (*embedded-renderer*): New. (eq-display): New. (eq)[:align-with]: New option. (eq-display): New text-based writer. (eq): Parameterize `*embedded-renderer*'. * src/guile/skribilo/package/eq/lout.scm (eq-display): New writer. (eq): Support `:align-with'. (simple-lout-markup-writer): Honor `:align-with'. git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-26 --- src/guile/skribilo/package/eq.scm | 62 +++++++++++++++++------- src/guile/skribilo/package/eq/lout.scm | 86 ++++++++++++++++++++-------------- 2 files changed, 95 insertions(+), 53 deletions(-) (limited to 'src/guile') diff --git a/src/guile/skribilo/package/eq.scm b/src/guile/skribilo/package/eq.scm index a3eb99c..76bbf6c 100644 --- a/src/guile/skribilo/package/eq.scm +++ b/src/guile/skribilo/package/eq.scm @@ -29,6 +29,8 @@ :use-module (skribilo utils keywords) ;; `the-options', etc. :autoload (skribilo package base) (it symbol sub sup) :autoload (skribilo engine lout) (lout-illustration) + + :use-module (srfi srfi-39) :use-module (ice-9 optargs)) ;;; Author: Ludovic Courtès @@ -52,6 +54,11 @@ ;;; Utilities. ;;; +(define-public *embedded-renderer* + ;; Tells whether an engine is invoked as an embedded renderer or as the + ;; native engine. + (make-parameter #f)) + (define %operators '(/ * + - = != ~= < > <= >= sqrt expt sum product script in notin apply limit combinations)) @@ -178,15 +185,25 @@ a symbol representing the mathematical operator denoted by @var{m} (e.g., ;;; Markup. ;;; +(define-markup (eq-display :rest opts :key (ident #f) (class "eq-display")) + (new container + (markup 'eq-display) + (ident (or ident (symbol->string (gensym "eq-display")))) + (class class) + (options (the-options opts :ident :class :div-style)) + (body (the-body opts)))) + (define-markup (eq :rest opts :key (ident #f) (class "eq") - (inline? #f) + (inline? #f) (align-with #f) (renderer #f) (div-style 'over)) (new container (markup 'eq) (ident (or ident (symbol->string (gensym "eq")))) (class class) - (options `((:div-style ,div-style) - ,@(the-options opts :ident :class :div-style))) + (options `((:div-style ,div-style) (:align-with ,align-with) + ,@(the-options opts + :ident :class + :div-style :align-with))) (body (let loop ((body (the-body opts)) (result '())) (if (null? body) @@ -199,6 +216,7 @@ a symbol representing the mathematical operator denoted by @var{m} (e.g., ;; passed )))))) + (define-markup (eq:/ :rest opts :key (ident #f) (div-style #f)) ;; If no `:div-style' is specified here, obey the top-level one. (new markup @@ -295,6 +313,15 @@ a symbol representing the mathematical operator denoted by @var{m} (e.g., ;;; +(markup-writer 'eq-display (find-engine 'base) + :action (lambda (node engine) + (for-each (lambda (node) + (let ((eq? (is-markup? node 'eq))) + (if eq? (output (linebreak) engine)) + (output node engine) + (if eq? (output (linebreak) engine)))) + (markup-body node)))) + (markup-writer 'eq (find-engine 'base) :action (lambda (node engine) ;; The `:renderer' option should be a symbol (naming an engine @@ -306,20 +333,21 @@ a symbol representing the mathematical operator denoted by @var{m} (e.g., (cond ((not renderer) ;; default: use the current engine (output (it (markup-body node)) engine)) ((symbol? renderer) - (case renderer - ;; FIXME: We should have an `embed' slot for each - ;; engine class similar to `lout-illustration'. - ((lout) - (let ((lout-code - (with-output-to-string - (lambda () - (output node (find-engine 'lout)))))) - (output (lout-illustration - :ident (markup-ident node) - lout-code) - engine))) - (else - (skribe-error 'eq "invalid renderer" renderer)))) + (parameterize ((*embedded-renderer* #t)) + (case renderer + ;; FIXME: We should have an `embed' slot for each + ;; engine class similar to `lout-illustration'. + ((lout) + (let ((lout-code + (with-output-to-string + (lambda () + (output node (find-engine 'lout)))))) + (output (lout-illustration + :ident (markup-ident node) + lout-code) + engine))) + (else + (skribe-error 'eq "invalid renderer" renderer))))) ;; FIXME: `engine?' and `engine-class?' (else (skribe-error 'eq "`:renderer' -- wrong argument type" diff --git a/src/guile/skribilo/package/eq/lout.scm b/src/guile/skribilo/package/eq/lout.scm index 9cd594b..b1ff7ae 100644 --- a/src/guile/skribilo/package/eq/lout.scm +++ b/src/guile/skribilo/package/eq/lout.scm @@ -51,10 +51,18 @@ ;;; Simple markup writers. ;;; +(markup-writer 'eq-display (find-engine 'lout) + :before "\n@BeginAlignedDisplays\n" + :after "\n@EndAlignedDisplays\n") (markup-writer 'eq (find-engine 'lout) - :options '(:inline? :div-style) - :before "{ " + :options '(:inline? :align-with :div-style) + :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 " "")))) :action (lambda (node engine) (display (if (markup-option node :inline?) "@E { " @@ -92,40 +100,46 @@ `(if need-paren? "{ @VScale ) }" "") ""))) - `(markup-writer ',(symbol-append 'eq: sym) - (find-engine 'lout) - :action (lambda (node engine) - (let ((lout-name ,(if (string? lout-name) - lout-name - `(,lout-name node - engine)))) - (let loop ((operands (markup-body node))) - (if (null? operands) - #t - (let* ((op (car operands)) - (eq-op? (equation-markup? op)) - (need-paren? - (and eq-op? - (>= (operator-precedence - (equation-markup-name->operator - (markup-markup op))) - ,precedence))) - (column (port-column - (current-output-port)))) - - ;; Work around Lout's limitations... - (if (> column 1000) (display "\n")) - - (display - (string-append " { " ,open-par)) - (output op engine) - (display - (string-append ,close-par " }")) - (if (pair? (cdr operands)) - (display (string-append " " - lout-name - " "))) - (loop (cdr operands)))))))))) + `(markup-writer ',(symbol-append 'eq: sym) (find-engine 'lout) + :action (lambda (node engine) + (let* ((lout-name ,(if (string? lout-name) + lout-name + `(,lout-name node + engine))) + (eq (ast-parent node)) + (eq-parent (ast-parent eq))) + + (let loop ((operands (markup-body node)) + (first? #t)) + (if (null? operands) + #t + (let* ((align? + (and first? + (is-markup? eq-parent 'eq-display) + (eq? ',sym + (markup-option eq :align-with)))) + (op (car operands)) + (eq-op? (equation-markup? op)) + (need-paren? + (and eq-op? + (>= (operator-precedence + (equation-markup-name->operator + (markup-markup op))) + ,precedence))) + (column (port-column (current-output-port)))) + + ;; Work around Lout's limitations... + (if (> column 1000) (display "\n")) + + (display (string-append " { " ,open-par)) + (output op engine) + (display (string-append ,close-par " }")) + (if (pair? (cdr operands)) + (display (string-append " " + (if align? "^" "") + lout-name + " "))) + (loop (cdr operands) #f))))))))) ;; `+' and `*' have higher precedence than `-', `/', `=', etc., so their -- cgit v1.2.3 From fd94a38600be0fa9103f598edabde9307aeea4b2 Mon Sep 17 00:00:00 2001 From: Ludovic Courtes Date: Sun, 3 Dec 2006 21:50:20 +0000 Subject: eq/lout: Fixed `limit'. * src/guile/skribilo/package/eq/lout.scm (eq:limit): Use `from' instead of `on'. git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-28 --- ChangeLog | 117 +++++++++++++++++++++++++++++++++ src/guile/skribilo/package/eq/lout.scm | 2 +- 2 files changed, 118 insertions(+), 1 deletion(-) (limited to 'src/guile') diff --git a/ChangeLog b/ChangeLog index f0cafb4..07f35bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,123 @@ # arch-tag: automatic-ChangeLog--lcourtes@laas.fr--2005-mobile/skribilo--devel--1.2 # +2006-12-03 17:35:08 GMT Ludovic Courtes patch-86 + + Summary: + eq/lout: Fixed `limit'. + Revision: + skribilo--devel--1.2--patch-86 + + * src/guile/skribilo/package/eq/lout.scm (eq:limit): Use `from' instead + of `on'. + + modified files: + ChangeLog src/guile/skribilo/package/eq/lout.scm + + +2006-12-02 10:56:17 GMT Ludovic Courtes patch-85 + + Summary: + Merge from skribilo@sv.gnu.org--2006/skribilo--devo--1.2 + Revision: + skribilo--devel--1.2--patch-85 + + Patches applied: + + * lcourtes@laas.fr--2005-libre/skribilo--devo--1.2 (patch 80-85) + * skribilo@sv.gnu.org--2006/skribilo--devo--1.2 (patch 22-27) + + - eq: Added the `:div-style' option. + - doc: Documented `eq' and the `:div-style' option. + - eq: Added `limit' and `combinations'. + - eq: Properly handle operator precedence. + - eq: Added `eq-display' and the `:align-with' option for `eq'. + - doc: Augmented the `eq' doc, documented `eq-display'. + + new files: + doc/user/src/.arch-ids/eq3.skb.id doc/user/src/eq3.skb + + modified files: + ChangeLog doc/user/char.skb doc/user/eq.skb + src/guile/skribilo/package/eq.scm + src/guile/skribilo/package/eq/lout.scm + + new patches: + lcourtes@laas.fr--2005-libre/skribilo--devo--1.2--patch-80 + lcourtes@laas.fr--2005-libre/skribilo--devo--1.2--patch-81 + lcourtes@laas.fr--2005-libre/skribilo--devo--1.2--patch-82 + lcourtes@laas.fr--2005-libre/skribilo--devo--1.2--patch-83 + lcourtes@laas.fr--2005-libre/skribilo--devo--1.2--patch-84 + lcourtes@laas.fr--2005-libre/skribilo--devo--1.2--patch-85 + skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-22 + skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-23 + skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-24 + skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-25 + skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-26 + skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-27 + + +2006-11-25 17:47:29 GMT Ludovic Courtes patch-84 + + Summary: + Merge from skribilo@sv.gnu.org--2006/skribilo--devo--1.2 + Revision: + skribilo--devel--1.2--patch-84 + + Patches applied: + + * lcourtes@laas.fr--2005-libre/skribilo--devo--1.2 (patch 72-79) + + - Merge from skribilo@sv.gnu.org--2006 + - Lout engine: Better cover sheet for `doc' documents. + - outline reader: Support keywords. + - lout: bib-ref+: Gracefully handle `unref' objects. + - Introduced `markup-number-string'. + - `base' package: Added `numref'. + - doc: Documented `numref'. + - Cleaned up `(skribilo biblio)' a bit. + + * skribilo@sv.gnu.org--2006/skribilo--devo--1.2 (patch 13-21) + + - Added the `(skribilo biblio template)' module. + - Lout engine: Make URLs breakable; make bibliography defaults sane. + - Lout engine: Better cover sheet for `doc' documents. + - outline reader: Support keywords. + - lout: bib-ref+: Gracefully handle `unref' objects. + - Introduced `markup-number-string'. + - `base' package: Added `numref'. + - doc: Documented `numref'. + - Cleaned up `(skribilo biblio)' a bit. + + modified files: + ChangeLog doc/user/bib.skb doc/user/links.skb + doc/user/src/links1.skb src/guile/skribilo/ast.scm + src/guile/skribilo/biblio.scm + src/guile/skribilo/engine/lout.scm + src/guile/skribilo/package/base.scm + src/guile/skribilo/reader/outline.scm + src/guile/skribilo/utils/compat.scm + + new patches: + lcourtes@laas.fr--2005-libre/skribilo--devo--1.2--patch-72 + lcourtes@laas.fr--2005-libre/skribilo--devo--1.2--patch-73 + lcourtes@laas.fr--2005-libre/skribilo--devo--1.2--patch-74 + lcourtes@laas.fr--2005-libre/skribilo--devo--1.2--patch-75 + lcourtes@laas.fr--2005-libre/skribilo--devo--1.2--patch-76 + lcourtes@laas.fr--2005-libre/skribilo--devo--1.2--patch-77 + lcourtes@laas.fr--2005-libre/skribilo--devo--1.2--patch-78 + lcourtes@laas.fr--2005-libre/skribilo--devo--1.2--patch-79 + skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-13 + skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-14 + skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-15 + skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-16 + skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-17 + skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-18 + skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-19 + skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-20 + skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-21 + + 2006-11-11 23:02:57 GMT Ludovic Courtes patch-83 Summary: diff --git a/src/guile/skribilo/package/eq/lout.scm b/src/guile/skribilo/package/eq/lout.scm index b1ff7ae..16d4513 100644 --- a/src/guile/skribilo/package/eq/lout.scm +++ b/src/guile/skribilo/package/eq/lout.scm @@ -210,7 +210,7 @@ (let ((body (markup-body node)) (var (markup-option node :var)) (limit (markup-option node :limit))) - (display "{ lim on { ") + (display "{ lim from { ") (output var engine) (display " --> ") (output limit engine) -- cgit v1.2.3 From a165a2604af8b9d222488a29eb5165c791fa2c73 Mon Sep 17 00:00:00 2001 From: Ludovic Courtes Date: Sun, 3 Dec 2006 21:51:27 +0000 Subject: eq/lout: Improved typesetting of parentheses. * src/guile/skribilo/package/eq/lout.scm (%left-paren): New. (%right-paren): New. (simple-lout-markup-writer): Use them. (binary-lout-markup-writer): Likewise. (eq:apply): Likewise. (eq:limit): Likewise. git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-29 --- ChangeLog | 18 ++++++++++++++++++ src/guile/skribilo/package/eq/lout.scm | 27 +++++++++++++++------------ 2 files changed, 33 insertions(+), 12 deletions(-) (limited to 'src/guile') diff --git a/ChangeLog b/ChangeLog index 07f35bd..c8e34a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,24 @@ # arch-tag: automatic-ChangeLog--lcourtes@laas.fr--2005-mobile/skribilo--devel--1.2 # +2006-12-03 19:00:42 GMT Ludovic Courtes patch-87 + + Summary: + eq/lout: Improved typesetting of parentheses. + Revision: + skribilo--devel--1.2--patch-87 + + * src/guile/skribilo/package/eq/lout.scm (%left-paren): New. + (%right-paren): New. + (simple-lout-markup-writer): Use them. + (binary-lout-markup-writer): Likewise. + (eq:apply): Likewise. + (eq:limit): Likewise. + + modified files: + ChangeLog src/guile/skribilo/package/eq/lout.scm + + 2006-12-03 17:35:08 GMT Ludovic Courtes patch-86 Summary: diff --git a/src/guile/skribilo/package/eq/lout.scm b/src/guile/skribilo/package/eq/lout.scm index 16d4513..cc4b3bf 100644 --- a/src/guile/skribilo/package/eq/lout.scm +++ b/src/guile/skribilo/package/eq/lout.scm @@ -73,6 +73,11 @@ :after " } }") +;; Scaled parenthesis. We could use `pmatrix' here but it precludes +;; line-breaking within equations. +(define %left-paren "{ Base @Font @VScale \"(\" }") +(define %right-paren "{ Base @Font @VScale \")\" }") + (define (div-style->lout style) (case style ((over) "over") @@ -91,13 +96,11 @@ (cadr args))) (precedence (operator-precedence sym)) - ;; Note: We could use `pmatrix' here but it precludes line-breaking - ;; within equations. (open-par (if parentheses? - `(if need-paren? "{ @VScale ( }" "") + `(if need-paren? %left-paren "") "")) (close-par (if parentheses? - `(if need-paren? "{ @VScale ) }" "") + `(if need-paren? %right-paren "") ""))) `(markup-writer ',(symbol-append 'eq: sym) (find-engine 'lout) @@ -175,9 +178,9 @@ (second (cadr body)) (parentheses? (equation-markup? first))) (display " { { ") - (if parentheses? (display "(")) + (if parentheses? (display %left-paren)) (output first engine) - (if parentheses? (display ")")) + (if parentheses? (display %right-paren)) (display ,(string-append " } " lout-name " { ")) (output second engine) (display " } } ")) @@ -185,15 +188,15 @@ "wrong number of arguments" body)))))) -(binary-lout-markup-writer expt "sup") -(binary-lout-markup-writer in "element") +(binary-lout-markup-writer expt "sup") +(binary-lout-markup-writer in "element") (binary-lout-markup-writer notin "notelement") (markup-writer 'eq:apply (find-engine 'lout) :action (lambda (node engine) (let ((func (car (markup-body node)))) (output func engine) - (display "(") + (display %left-paren) (let loop ((operands (cdr (markup-body node)))) (if (null? operands) #t @@ -202,7 +205,7 @@ (if (not (null? (cdr operands))) (display ", ")) (loop (cdr operands))))) - (display ")")))) + (display %right-paren)))) (markup-writer 'eq:limit (find-engine 'lout) @@ -214,9 +217,9 @@ (output var engine) (display " --> ") (output limit engine) - (display " } } (") + (display (string-append " } } @VContract { " %left-paren)) (output body engine) - (display ") ")))) + (display (string-append %right-paren " } "))))) (markup-writer 'eq:combinations (find-engine 'lout) :action (lambda (node engine) -- cgit v1.2.3 From 80a7bbc7174962aaeca389b1b1592dc74297d50f Mon Sep 17 00:00:00 2001 From: Ludovic Courtes Date: Sun, 3 Dec 2006 21:52:02 +0000 Subject: eq: Added support for `:mul-style'. * src/guile/skribilo/package/eq.scm (eq)[:mul-style]: New option. (eq*)[mul-style]: New option. * src/guile/skribilo/package/eq/lout.scm (eq)[options]: Added `:mul-style'. (mul-style->lout): New. (eq:*): Support `:mul-style'. git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-30 --- ChangeLog | 20 ++++++++++++++++++++ src/guile/skribilo/package/eq.scm | 21 ++++++++++++++++----- src/guile/skribilo/package/eq/lout.scm | 24 ++++++++++++++++++++++-- 3 files changed, 58 insertions(+), 7 deletions(-) (limited to 'src/guile') diff --git a/ChangeLog b/ChangeLog index c8e34a6..6198716 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,26 @@ # arch-tag: automatic-ChangeLog--lcourtes@laas.fr--2005-mobile/skribilo--devel--1.2 # +2006-12-03 19:21:19 GMT Ludovic Courtes patch-88 + + Summary: + eq: Added support for `:mul-style'. + Revision: + skribilo--devel--1.2--patch-88 + + * src/guile/skribilo/package/eq.scm (eq)[:mul-style]: New option. + (eq*)[mul-style]: New option. + + * src/guile/skribilo/package/eq/lout.scm (eq)[options]: Added + `:mul-style'. + (mul-style->lout): New. + (eq:*): Support `:mul-style'. + + modified files: + ChangeLog src/guile/skribilo/package/eq.scm + src/guile/skribilo/package/eq/lout.scm + + 2006-12-03 19:00:42 GMT Ludovic Courtes patch-87 Summary: diff --git a/src/guile/skribilo/package/eq.scm b/src/guile/skribilo/package/eq.scm index 76bbf6c..e783c89 100644 --- a/src/guile/skribilo/package/eq.scm +++ b/src/guile/skribilo/package/eq.scm @@ -190,20 +190,22 @@ a symbol representing the mathematical operator denoted by @var{m} (e.g., (markup 'eq-display) (ident (or ident (symbol->string (gensym "eq-display")))) (class class) - (options (the-options opts :ident :class :div-style)) + (options (the-options opts :ident :class)) (body (the-body opts)))) (define-markup (eq :rest opts :key (ident #f) (class "eq") (inline? #f) (align-with #f) - (renderer #f) (div-style 'over)) + (renderer #f) (div-style 'over) + (mul-style 'space)) (new container (markup 'eq) (ident (or ident (symbol->string (gensym "eq")))) (class class) (options `((:div-style ,div-style) (:align-with ,align-with) + (:mul-style ,mul-style) ,@(the-options opts :ident :class - :div-style :align-with))) + :div-style :mul-style :align-with))) (body (let loop ((body (the-body opts)) (result '())) (if (null? body) @@ -224,10 +226,19 @@ a symbol representing the mathematical operator denoted by @var{m} (e.g., (ident (or ident (symbol->string (gensym "eq:/")))) (class #f) (options `((:div-style ,div-style) - ,@(the-options opts :ident :class :div-style))) + ,@(the-options opts :ident :div-style))) + (body (the-body opts)))) + +(define-markup (eq:* :rest opts :key (ident #f) (mul-style #f)) + ;; If no `:mul-style' is specified here, obey the top-level one. + (new markup + (markup 'eq:*) + (ident (or ident (symbol->string (gensym "eq:*")))) + (class #f) + (options `((:mul-style ,mul-style) + ,@(the-options opts :ident :mul-style))) (body (the-body opts)))) -(define-simple-markup eq:*) (define-simple-markup eq:+) (define-simple-markup eq:-) diff --git a/src/guile/skribilo/package/eq/lout.scm b/src/guile/skribilo/package/eq/lout.scm index cc4b3bf..c8ea50a 100644 --- a/src/guile/skribilo/package/eq/lout.scm +++ b/src/guile/skribilo/package/eq/lout.scm @@ -56,7 +56,7 @@ :after "\n@EndAlignedDisplays\n") (markup-writer 'eq (find-engine 'lout) - :options '(:inline? :align-with :div-style) + :options '(:inline? :align-with :div-style :mul-style) :before (lambda (node engine) (let* ((parent (ast-parent node)) (displayed? (is-markup? parent 'eq-display))) @@ -87,6 +87,16 @@ (else (error "unsupported div style" style)))) +(define (mul-style->lout style) + (case style + ((space) "") + ((cross) "times") + ((asterisk) "*") + ((dot) "cdot") + (else + (error "unsupported mul style" style)))) + + (define-macro (simple-lout-markup-writer sym . args) (let* ((lout-name (if (null? args) (symbol->string sym) @@ -151,8 +161,18 @@ (simple-lout-markup-writer +) -(simple-lout-markup-writer * "times") (simple-lout-markup-writer - "-") + +(simple-lout-markup-writer * + (lambda (n e) + ;; Obey either the per-node `:mul-style' or the + ;; top-level one. + (or (markup-option n :mul-style) + (let* ((eq (ast-parent n)) + (mul-style + (markup-option eq :mul-style))) + (mul-style->lout mul-style))))) + (simple-lout-markup-writer / (lambda (n e) ;; Obey either the per-node `:div-style' or the -- cgit v1.2.3 From 1eecf11d36df1ec53f22f9882199abf481bd7494 Mon Sep 17 00:00:00 2001 From: Ludovic Courtes Date: Sun, 3 Dec 2006 21:52:40 +0000 Subject: eq/lout: Fixed binomial coefficient. * src/guile/skribilo/package/eq/lout.scm (eq:combinations): Fixed spacing, use `lpar' instead of `blpar' (according to "The TeXbook"), changed order of OF and AMONG. git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-31 --- ChangeLog | 15 +++++++++++++++ src/guile/skribilo/package/eq/lout.scm | 8 ++++---- 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'src/guile') diff --git a/ChangeLog b/ChangeLog index 6198716..c95106b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,21 @@ # arch-tag: automatic-ChangeLog--lcourtes@laas.fr--2005-mobile/skribilo--devel--1.2 # +2006-12-03 19:31:45 GMT Ludovic Courtes patch-89 + + Summary: + eq/lout: Fixed binomial coefficient. + Revision: + skribilo--devel--1.2--patch-89 + + * src/guile/skribilo/package/eq/lout.scm (eq:combinations): Fixed + spacing, use `lpar' instead of `blpar' (according to "The TeXbook"), + changed order of OF and AMONG. + + modified files: + ChangeLog src/guile/skribilo/package/eq/lout.scm + + 2006-12-03 19:21:19 GMT Ludovic Courtes patch-88 Summary: diff --git a/src/guile/skribilo/package/eq/lout.scm b/src/guile/skribilo/package/eq/lout.scm index c8ea50a..2c7b1bb 100644 --- a/src/guile/skribilo/package/eq/lout.scm +++ b/src/guile/skribilo/package/eq/lout.scm @@ -245,12 +245,12 @@ :action (lambda (node engine) (let ((of (markup-option node :of)) (among (markup-option node :among))) - (display " { matrix atleft { blpar } atright { brpar } { ") + (display " ` { matrix atleft { lpar } atright { rpar } { ") (display "row col { ") - (output among engine) - (display " } row col { ") (output of engine) - (display " } } }\n")))) + (display " } row col { ") + (output among engine) + (display " } } } `\n")))) ;;; -- cgit v1.2.3 From 7996e5b2dddf1321d03b52635367a90cefa85c8d Mon Sep 17 00:00:00 2001 From: Ludovic Courtes Date: Sun, 3 Dec 2006 21:53:41 +0000 Subject: eq: Support automatic detection of inlining. * src/guile/skribilo/package/eq.scm (inline-equation?): New. (eq)[inline?]: Default to `auto'. * src/guile/skribilo/package/eq/lout.scm (eq): Use `inline-equation?'. git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-32 --- ChangeLog | 17 +++++++++++++++++ src/guile/skribilo/package/eq.scm | 16 ++++++++++++++-- src/guile/skribilo/package/eq/lout.scm | 2 +- 3 files changed, 32 insertions(+), 3 deletions(-) (limited to 'src/guile') diff --git a/ChangeLog b/ChangeLog index c95106b..4a740d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,23 @@ # arch-tag: automatic-ChangeLog--lcourtes@laas.fr--2005-mobile/skribilo--devel--1.2 # +2006-12-03 19:59:46 GMT Ludovic Courtes patch-90 + + Summary: + eq: Support automatic detection of inlining. + Revision: + skribilo--devel--1.2--patch-90 + + * src/guile/skribilo/package/eq.scm (inline-equation?): New. + (eq)[inline?]: Default to `auto'. + + * src/guile/skribilo/package/eq/lout.scm (eq): Use `inline-equation?'. + + modified files: + ChangeLog src/guile/skribilo/package/eq.scm + src/guile/skribilo/package/eq/lout.scm + + 2006-12-03 19:31:45 GMT Ludovic Courtes patch-89 Summary: diff --git a/src/guile/skribilo/package/eq.scm b/src/guile/skribilo/package/eq.scm index e783c89..cadc1ba 100644 --- a/src/guile/skribilo/package/eq.scm +++ b/src/guile/skribilo/package/eq.scm @@ -19,7 +19,7 @@ ;;; USA. (define-module (skribilo package eq) - :autoload (skribilo ast) (markup?) + :autoload (skribilo ast) (markup? find-up) :autoload (skribilo output) (output) :use-module (skribilo writer) :use-module (skribilo engine) @@ -117,6 +117,18 @@ a symbol representing the mathematical operator denoted by @var{m} (e.g., (string-length str)))) #f)) +(define-public (inline-equation? m) + "Return @code{#t} if @var{m} is an equation that is to be displayed inline." + (and (is-markup? m 'eq) + (let ((i (markup-option m :inline?))) + (case i + ((auto) + (not (find-up (lambda (n) + (is-markup? n 'eq-display)) + m))) + ((#t) #t) + (else #f))))) + ;;; ;;; Operator precedence. @@ -194,7 +206,7 @@ a symbol representing the mathematical operator denoted by @var{m} (e.g., (body (the-body opts)))) (define-markup (eq :rest opts :key (ident #f) (class "eq") - (inline? #f) (align-with #f) + (inline? 'auto) (align-with #f) (renderer #f) (div-style 'over) (mul-style 'space)) (new container diff --git a/src/guile/skribilo/package/eq/lout.scm b/src/guile/skribilo/package/eq/lout.scm index 2c7b1bb..e08e6d1 100644 --- a/src/guile/skribilo/package/eq/lout.scm +++ b/src/guile/skribilo/package/eq/lout.scm @@ -64,7 +64,7 @@ (if (and displayed? (not (*embedded-renderer*))) "\n@IAD " "")))) :action (lambda (node engine) - (display (if (markup-option node :inline?) + (display (if (inline-equation? node) "@E { " "@Eq { ")) (let ((eq (markup-body node))) -- cgit v1.2.3