From 53fdd079f27d846cb983437bf1d2ad669876a09f Mon Sep 17 00:00:00 2001 From: Ludovic Court`es Date: Wed, 1 Feb 2006 17:07:08 +0000 Subject: 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 --- src/guile/skribilo/reader/outline.scm | 67 ++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 25 deletions(-) (limited to 'src') 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)) -- cgit v1.2.3