aboutsummaryrefslogtreecommitdiff
path: root/src/guile
diff options
context:
space:
mode:
authorLudovic Court`es2006-02-27 16:02:14 +0000
committerLudovic Court`es2006-02-27 16:02:14 +0000
commit332e3b7f3c359e19f20df5ca2f7ca595d8ecba64 (patch)
tree125ee6ab09d1fd616e7a73baff6c6215052d326a /src/guile
parent85bc77eef9715f726eefe71ac74ecf6e17656bf5 (diff)
downloadskribilo-332e3b7f3c359e19f20df5ca2f7ca595d8ecba64.tar.gz
skribilo-332e3b7f3c359e19f20df5ca2f7ca595d8ecba64.tar.lz
skribilo-332e3b7f3c359e19f20df5ca2f7ca595d8ecba64.zip
`eq': Added the `:renderer' option to `eq'. Support `lout'.
* src/guile/skribilo/package/eq.scm (eq): Added a `renderer' option. Modified the `eq' writer for `base'. (!=): Use the appropriate symbol. (~=): Likewise. (>=): Likewise. (<=): Likewise. git-archimport-id: lcourtes@laas.fr--2004-libre/skribilo--devel--1.2--patch-57
Diffstat (limited to 'src/guile')
-rw-r--r--src/guile/skribilo/package/eq.scm45
1 files changed, 38 insertions, 7 deletions
diff --git a/src/guile/skribilo/package/eq.scm b/src/guile/skribilo/package/eq.scm
index 8a4ad3b..45a863f 100644
--- a/src/guile/skribilo/package/eq.scm
+++ b/src/guile/skribilo/package/eq.scm
@@ -28,6 +28,7 @@
:use-module (skribilo module)
:use-module (skribilo skribe utils) ;; `the-options', etc.
:autoload (skribilo skribe api) (it symbol sub sup)
+ :autoload (skribilo engine lout) (lout-illustration)
:use-module (ice-9 optargs))
;;; Author: Ludovic Courtès
@@ -126,7 +127,7 @@
;;; Markup.
;;;
-(define-markup (eq :rest opts :key (ident #f) (class "eq"))
+(define-markup (eq :rest opts :key (ident #f) (renderer #f) (class "eq"))
(new markup
(markup 'eq)
(ident (or ident (symbol->string (gensym "eq"))))
@@ -209,12 +210,40 @@
;;;
-;;; Text-only implementation.
+;;; Base and text-only implementation.
;;;
+
+
(markup-writer 'eq (find-engine 'base)
:action (lambda (node engine)
- (output (it (markup-body node)) engine)))
+ ;; The `:renderer' option should be a symbol (naming an engine
+ ;; class) or an engine or engine class. This allows the use of
+ ;; another engine to render equations. For instance, equations
+ ;; may be rendered using the Lout engine within an HTML
+ ;; document.
+ (let ((renderer (markup-option node :renderer)))
+ (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))))
+ ;; FIXME: `engine?' and `engine-class?'
+ (else
+ (skribe-error 'eq "`:renderer' -- wrong argument type"
+ renderer))))))
(define-macro (simple-markup-writer op . obj)
`(markup-writer ',(symbol-append 'eq: op) (find-engine 'base)
@@ -242,12 +271,12 @@
(simple-markup-writer * (symbol "times"))
(simple-markup-writer =)
-(simple-markup-writer !=)
-(simple-markup-writer ~=)
+(simple-markup-writer != (symbol "neq"))
+(simple-markup-writer ~= (symbol "approx"))
(simple-markup-writer <)
(simple-markup-writer >)
-(simple-markup-writer >=)
-(simple-markup-writer <=)
+(simple-markup-writer >= (symbol "ge"))
+(simple-markup-writer <= (symbol "le"))
(markup-writer 'eq:sqrt (find-engine 'base)
:action (lambda (node engine)
@@ -337,6 +366,8 @@
(output (sup sup*) engine)
(output (sub sub*) engine))))
+
+
;;;
;;; Initialization.