From 60531ac43e86c0cfdc6163eed3aeb656aaa56720 Mon Sep 17 00:00:00 2001 From: Ludovic Court`es Date: Fri, 17 Feb 2006 13:21:55 +0000 Subject: `eq' package: added the `script' markup. * src/guile/skribilo/package/eq.scm (%operators): Added `script'. (eq:script): New. (eq:expt): Fixed wrong braces. git-archimport-id: lcourtes@laas.fr--2004-libre/skribilo--devel--1.2--patch-48 --- src/guile/skribilo/package/eq.scm | 40 ++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/src/guile/skribilo/package/eq.scm b/src/guile/skribilo/package/eq.scm index 1ac8d35..9be8f61 100644 --- a/src/guile/skribilo/package/eq.scm +++ b/src/guile/skribilo/package/eq.scm @@ -50,7 +50,7 @@ ;;; (define %operators - '(/ * + - = != ~= < > <= >= sqrt expt sum product)) + '(/ * + - = != ~= < > <= >= sqrt expt sum product script)) (define %rebindings (map (lambda (sym) @@ -129,6 +129,14 @@ (options (the-options opts)) (body (the-body opts)))) +(define-markup (eq:script :rest opts :key (ident #f) (class "eq:script") + (sub #f) (sup #f)) + (new markup + (markup 'eq:script) + (ident (or ident (symbol->string (gensym "eq:script")))) + (options (the-options opts)) + (body (the-body opts)))) + ;;; @@ -216,11 +224,14 @@ :action (lambda (node engine) (let ((body (markup-body node))) (if (= (length body) 2) - (begin + (let ((base (car body)) + (expt (cadr body))) (display " { { ") - (output (car body) engine) + (if (markup? base) (display "(")) + (output base engine) + (if (markup? base) (display ")")) (display " } sup { ") - (output (cadr body) engine) + (output expt engine) (display " } } ")) (skribe-error 'eq:expt "wrong number of arguments" body))))) @@ -243,11 +254,30 @@ (output to engine) (display " } { ") (output body engine) - (display " } "))))) + (display " } } "))))) (range-lout-markup-writer sum "sum") (range-lout-markup-writer product "prod") +(markup-writer 'eq:script (find-engine 'lout) + :action (lambda (node engine) + (let ((body (markup-body node)) + (sup (markup-option node :sup)) + (sub (markup-option node :sub))) + (display " { { ") + (output body engine) + (display " } ") + (if sup + (begin + (display (if sub " supp { " " sup { ")) + (output sup engine) + (display " } "))) + (if sub + (begin + (display " on { ") + (output sub engine) + (display " } "))) + (display " } ")))) ;;; -- cgit v1.2.3