From 5a6bebf5847259c8fb8259411cd2f125cb1324bc Mon Sep 17 00:00:00 2001
From: Ludovic Courtès
Date: Tue, 20 Nov 2012 23:18:05 +0100
Subject: html: Fix footnote handling for single-page documents.

* src/guile/skribilo/engine/html.scm (&html-generic-document)[ftnote](body):
  Rewrite using `match'.  Deal with the case where `container-env-get'
  returns #f.  Append FOOTNOTES to the result of `container-env-get'
  when it's not.  The latter fixes a problem whereby footnotes would not
  appear on single-page documents.
  Reported and analyzed by Klaus Schilling <schilling.klaus@web.de>.
---
 src/guile/skribilo/engine/html.scm | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

(limited to 'src/guile')

diff --git a/src/guile/skribilo/engine/html.scm b/src/guile/skribilo/engine/html.scm
index 5dad3bc..f628bfa 100644
--- a/src/guile/skribilo/engine/html.scm
+++ b/src/guile/skribilo/engine/html.scm
@@ -39,6 +39,7 @@
   :autoload   (skribilo sui)           (document-sui)
   :autoload   (ice-9 rdelim)           (read-line)
   :autoload   (ice-9 regex)            (regexp-substitute/global)
+  :use-module (ice-9 match)
 
   :use-module (srfi srfi-1)
   :use-module (srfi srfi-13)
@@ -1205,20 +1206,24 @@
 		     (body
                       ;; Collect the footnotes of all the sub-containers that
                       ;; are to be output in the same file.
-                      (let ((subsections
-                             (find-down (lambda (s)
+                      (match (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)))))))))
+                                        n)
+                        ((containers ...)
+                         (reverse
+                          (let loop ((subsections (cons n containers))
+                                     (footnotes   '()))
+                            (match subsections
+                              ((subsections ...)
+                               (fold loop footnotes subsections))
+                              (()
+                               footnotes)
+                              (container
+                               (append footnotes
+                                       (or (container-env-get container
+                                                              'footnote-env)
+                                           '())))))))
+                        (_ #f)))))
 	  (page (new markup
 		   (markup '&html-page)
 		   (ident (string-append id "-page"))
-- 
cgit v1.2.3