diff options
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | src/guile/skribilo/engine/html.scm | 38 |
2 files changed, 40 insertions, 2 deletions
@@ -15,6 +15,10 @@ Copyright (C) 2005, 2006, 2007, 2008, 2009 Ludovic Courtès <ludo@gnu.org> ** Using `(image :url ...)' with `lout' yields a warning, not an error ** New `rss-2' input syntax, for RSS 2.0 feeds ** HTML engine: footnotes now yield hyperlinks back to the call site +** HTML engine: footnotes are properly printed for same-file chapters + +Previously, footnotes would not get printed in the case of chapters that +are not output in a separate file. * New in Skribilo 0.9.1 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 "</tbody>\n</table>\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")) |