From d05d352ea3e8af3dbd53a021f83532198cd5cce6 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 7 Jan 2009 01:35:04 +0100 Subject: html: Fix footnote output for chapters that are not in a separate file. * src/guile/skribilo/engine/html.scm (section-in-separate-file?, section-in-current-file?): New. (&html-generic-document)[ftnotes]: Collect the footnotes not only of N but also those of all its sub-containers that are to be output in the same file. This fixes a bug where chapters that are not output in the same file don't get their footnotes printed. Reported by Klaus Schilling . * NEWS: Update. --- src/guile/skribilo/engine/html.scm | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'src/guile/skribilo/engine/html.scm') diff --git a/src/guile/skribilo/engine/html.scm b/src/guile/skribilo/engine/html.scm index 0fded86..9f969c5 100644 --- a/src/guile/skribilo/engine/html.scm +++ b/src/guile/skribilo/engine/html.scm @@ -39,6 +39,7 @@ :autoload (ice-9 rdelim) (read-line) :autoload (ice-9 regex) (regexp-substitute/global) + :use-module (srfi srfi-1) :use-module (srfi srfi-13) :use-module (srfi srfi-14) :use-module (srfi srfi-39) @@ -1137,6 +1138,23 @@ (display "\n\n"))))))) +(define (section-in-separate-file? n e) + ;; Return true if N, a node (chapter, section, etc.), is to be put in a + ;; separate file, according to the customs of engine E. + (and (container? n) + (not (document? n)) + (or (markup-option n :file) + (let ((kind (markup-markup n))) + (engine-custom e (string->symbol + (string-append (symbol->string kind) + "-file"))))))) + +(define (section-in-current-file? n e) + ;; Return true if N is to be output in the current file, or in the main + ;; file. + (and (container? n) + (not (section-in-separate-file? n e)))) + ;*---------------------------------------------------------------------*/ ;* &html-generic-document ... */ ;*---------------------------------------------------------------------*/ @@ -1165,8 +1183,24 @@ (ident (string-append id "-footnote")) (class (markup-class n)) (parent n) - (body (reverse! - (container-env-get n 'footnote-env))))) + + (body + ;; Collect the footnotes of all the sub-containers that + ;; are to be output in the same file. + (let ((subsections + (find-down (lambda (s) + (section-in-current-file? s e)) + n))) + (reverse + (let loop ((subsections (cons n subsections)) + (footnotes '())) + (cond ((pair? subsections) + (fold loop footnotes subsections)) + ((null? subsections) + footnotes) + (else + (container-env-get subsections + 'footnote-env))))))))) (page (new markup (markup '&html-page) (ident (string-append id "-page")) -- cgit v1.2.3