diff options
author | Ludovic Courtès | 2008-11-20 23:29:48 +0100 |
---|---|---|
committer | Ludovic Courtès | 2008-11-20 23:29:48 +0100 |
commit | 7e714df1ef0dfa3ccaeddfbdb86d5ce2bca8c7d6 (patch) | |
tree | 0443e48ed7f2ca3a4b9c58707dc2b76fa3e21657 | |
parent | 90c67b504f0495f15787b81e8325f1d5824e0a41 (diff) | |
download | skribilo-7e714df1ef0dfa3ccaeddfbdb86d5ce2bca8c7d6.tar.gz skribilo-7e714df1ef0dfa3ccaeddfbdb86d5ce2bca8c7d6.tar.lz skribilo-7e714df1ef0dfa3ccaeddfbdb86d5ce2bca8c7d6.zip |
Add `(skribilo table)'.
-rw-r--r-- | src/guile/skribilo/table.scm | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/guile/skribilo/table.scm b/src/guile/skribilo/table.scm new file mode 100644 index 0000000..440264f --- /dev/null +++ b/src/guile/skribilo/table.scm @@ -0,0 +1,57 @@ +;;; table.scm -- Routines to operate on `table' markups. +;;; +;;; Copyright 2008 Ludovic Courtès <ludo@gnu.org> +;;; Copyright 2001 Manuel Serrano +;;; +;;; +;;; This program is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 2 of the License, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program; if not, write to the Free Software +;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +;;; USA. + +(define-module (skribilo table) + :use-module (skribilo ast) + :use-module (skribilo utils syntax) + + :export (table-column-count)) + +;;; Author: Manuel Serrano, Ludovic Courtès +;;; +;;; Commentary: +;;; +;;; This module provides utility functions to operate on `table' ASTs. It is +;;; partly based on code from Scribe 1.1a. +;;; +;;; Code: + +(fluid-set! current-reader %skribilo-module-reader) + + +(define (table-column-count t) + ;; Return the number of columns contained in table T. + (define (row-columns row) + (let loop ((cells (markup-body row)) + (nbcols 0)) + (if (null? cells) + nbcols + (loop (cdr cells) + (+ nbcols (markup-option (car cells) :colspan)))))) + + (let loop ((rows (markup-body t)) + (nbcols 0)) + (if (null? rows) + nbcols + (loop (cdr rows) + (max (row-columns (car rows)) nbcols))))) + +;;; table.scm ends here |