summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Court`es2006-02-01 17:07:08 +0000
committerLudovic Court`es2006-02-01 17:07:08 +0000
commit53fdd079f27d846cb983437bf1d2ad669876a09f (patch)
tree980fec9566c2d5e006efbf2118d741a95cce4730
parentb3a4dbb047b56a9ba0a332b6e1e7525491f3c85d (diff)
downloadskribilo-53fdd079f27d846cb983437bf1d2ad669876a09f.tar.gz
skribilo-53fdd079f27d846cb983437bf1d2ad669876a09f.tar.lz
skribilo-53fdd079f27d846cb983437bf1d2ad669876a09f.zip
Added support for subsections and subsubsections in the outline reader.
* src/guile/skribilo/reader/outline.scm (make-node-processor): Consider the END-OF-NODE? case _after_ the SUBNODE case. (%node-processors): Added support for subsections and subsubsections. git-archimport-id: lcourtes@laas.fr--2004-libre/skribilo--devel--1.2--patch-39
-rw-r--r--src/guile/skribilo/reader/outline.scm67
1 files changed, 42 insertions, 25 deletions
diff --git a/src/guile/skribilo/reader/outline.scm b/src/guile/skribilo/reader/outline.scm
index 688fcdc..d7e2778 100644
--- a/src/guile/skribilo/reader/outline.scm
+++ b/src/guile/skribilo/reader/outline.scm
@@ -204,26 +204,27 @@ header, then the rest of the node is read from @var{port}."
(let ((title (line-proc (title-proc match))))
(let loop ((line (read-line port))
(body '()))
- (cond ((or (eof-object? line)
- (regexp-exec rx line)
- (and (procedure? end-of-node?)
- (end-of-node? line)))
- (values line
- `(,node-type :title ,title ,@(reverse! body))))
-
- ((empty-line? line)
- (loop (read-line port) body))
-
- (else
- (let ((subnode (and subnode-proc
- (apply subnode-proc
- (list line port)))))
- (if subnode
- (let-values (((line node) subnode))
- (loop line (cons node body)))
+
+ (let ((subnode (and (not (eof-object? line)) subnode-proc
+ (apply subnode-proc (list line port)))))
+ (cond (subnode
+ (let-values (((line node) subnode))
+ (loop line (cons node body))))
+
+ ((or (eof-object? line)
+ (regexp-exec rx line)
+ (and (procedure? end-of-node?)
+ (end-of-node? line)))
+ (values line
+ `(,node-type :title ,title ,@(reverse! body))))
+
+ ((empty-line? line)
+ (loop (read-line port) body))
+
+ (else
(let ((par (process-paragraph line line-proc port)))
(loop (read-line port)
- (cons par body)))))))))))))
+ (cons par body))))))))))))
(define (node-markup-line? line)
@@ -231,13 +232,29 @@ header, then the rest of the node is read from @var{port}."
(regexp-exec node-rx line))
(define %node-processors
- (let ((section-proc
- (make-node-processor (make-regexp "^\\*\\* (.+)$" regexp/extended)
- 'section
- (lambda (m) (match:substring m 1))
- %line-processor
- #f
- node-markup-line?)))
+ (let* ((subsubsection-proc
+ (make-node-processor (make-regexp "^\\*\\*\\*\\* (.+)$"
+ regexp/extended)
+ 'subsection
+ (lambda (m) (match:substring m 1))
+ %line-processor
+ #f ;; no further subnodes
+ node-markup-line?))
+ (subsection-proc
+ (make-node-processor (make-regexp "^\\*\\*\\* (.+)$"
+ regexp/extended)
+ 'subsection
+ (lambda (m) (match:substring m 1))
+ %line-processor
+ subsubsection-proc
+ node-markup-line?))
+ (section-proc
+ (make-node-processor (make-regexp "^\\*\\* (.+)$" regexp/extended)
+ 'section
+ (lambda (m) (match:substring m 1))
+ %line-processor
+ subsection-proc
+ node-markup-line?)))
(list (make-node-processor (make-regexp "^\\* (.+)$" regexp/extended)
'chapter
(lambda (m) (match:substring m 1))