From 8fe4d235248bc54d4cf6c204d0267276647e0bd9 Mon Sep 17 00:00:00 2001 From: Ludovic Court`es Date: Fri, 16 Mar 2007 12:43:45 +0000 Subject: `eq' package: Added `eq:set'. * src/guile/skribilo/package/eq.scm: Use `(srfi srfi-1)'. (%operators): Added `set'. (eq:set): New. New writer. * src/guile/skribilo/package/eq/lout.scm: Use `srfi-1'. (eq:set): New writer. git-archimport-id: lcourtes@laas.fr--2006-libre/skribilo--devo--1.2--patch-26 --- src/guile/skribilo/package/eq.scm | 29 +++++++++++++++++++++++++++-- src/guile/skribilo/package/eq/lout.scm | 25 ++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 3 deletions(-) (limited to 'src/guile') diff --git a/src/guile/skribilo/package/eq.scm b/src/guile/skribilo/package/eq.scm index cadc1ba..af2c906 100644 --- a/src/guile/skribilo/package/eq.scm +++ b/src/guile/skribilo/package/eq.scm @@ -1,6 +1,6 @@ ;;; eq.scm -- An equation formatting package. ;;; -;;; Copyright 2005, 2006 Ludovic Courtès +;;; Copyright 2005, 2006, 2007 Ludovic Courtès ;;; ;;; ;;; This program is free software; you can redistribute it and/or modify @@ -30,6 +30,7 @@ :autoload (skribilo package base) (it symbol sub sup) :autoload (skribilo engine lout) (lout-illustration) + :use-module (srfi srfi-1) :use-module (srfi srfi-39) :use-module (ice-9 optargs)) @@ -61,7 +62,7 @@ (define %operators '(/ * + - = != ~= < > <= >= sqrt expt sum product script - in notin apply limit combinations)) + in notin apply limit combinations set)) (define %symbols ;; A set of symbols that are automatically recognized within an `eq' quoted @@ -330,6 +331,13 @@ a symbol representing the mathematical operator denoted by @var{m} (e.g., ,@(the-options opts :ident))) (body (the-body opts)))) +(define-markup (eq:set :rest opts :key (ident #f)) + (new markup + (markup 'eq:set) + (ident (or ident (symbol->string (gensym "eq:set")))) + (options '()) + (body (the-body opts)))) + ;;; ;;; Text-based rendering. @@ -533,6 +541,23 @@ a symbol representing the mathematical operator denoted by @var{m} (e.g., (output among engine) (display ")")))) +(markup-writer 'eq:set (find-engine 'base) + ;; Take the elements of the set and enclose them into braces. + :action (lambda (node engine) + (define (printable elem) + (if (eq? elem '...) + (symbol "ellipsis") + elem)) + + (output "{ " engine) + (pair-for-each (lambda (pair) + (let ((elem (printable (car pair)))) + (output elem engine) + (if (not (null? (cdr pair))) + (output ", " engine)))) + (markup-body node)) + (output " }" engine))) + ;;; diff --git a/src/guile/skribilo/package/eq/lout.scm b/src/guile/skribilo/package/eq/lout.scm index 21e8f92..5633ae4 100644 --- a/src/guile/skribilo/package/eq/lout.scm +++ b/src/guile/skribilo/package/eq/lout.scm @@ -1,6 +1,6 @@ ;;; lout.scm -- Lout implementation of the `eq' package. ;;; -;;; Copyright 2005, 2006 Ludovic Courtès +;;; Copyright 2005, 2006, 2007 Ludovic Courtès ;;; ;;; ;;; This program is free software; you can redistribute it and/or modify @@ -27,6 +27,7 @@ :use-module (skribilo lib) :use-module (skribilo utils syntax) :use-module (skribilo utils keywords) ;; `the-options', etc. + :use-module (srfi srfi-1) :use-module (ice-9 optargs)) (fluid-set! current-reader %skribilo-module-reader) @@ -293,5 +294,27 @@ (display " } "))) (display " } ")))) + +;;; +;;; Sets. +;;; + +(markup-writer 'eq:set (find-engine 'lout) + ;; Take the elements of the set and enclose them into braces. + :action (lambda (node engine) + (define (printable elem) + (if (eq? elem '...) + (symbol "ellipsis") + elem)) + + (display " brmatrix { ") + (pair-for-each (lambda (pair) + (let ((elem (printable (car pair)))) + (output elem engine) + (if (not (null? (cdr pair))) + (output ", " engine)))) + (markup-body node)) + (display " } "))) + ;;; arch-tag: 2a1410e5-977e-4600-b781-3d57f4409b35 -- cgit v1.2.3