[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[skribilo-users] (no subject)
From: |
Klaus Schilling |
Subject: |
[skribilo-users] (no subject) |
Date: |
Tue, 20 Nov 2012 08:55:47 +0100 (CET) |
Dear Mr. Cortes,
the footnote problem still persists in 0.9.2.
If there are several chapters in a document, only the footnotes of the
last chapter get actually displayed.
If there is a chapter containing a section, skribilo exits prematurely
with an error in
src/guile/skribilo/engine/html.scm, line 1212. Note that this error
occurs whether there are actually footnotes in the document ot not. A
document as simple as
(document (chapter (section "")))
is enough to produce that bug.
This block of code is probably the culprit:
(ftnote (new markup
(markup '&html-footnotes)
(ident (string-append id "-footnote"))
(class (markup-class n))
(parent n)
(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)))))))))
More precisely, if there is a chapter with a section, the argument
given to `reverse' evaluates to `#f', which is of course not a valid
argument for `reverse'.
Unfortunately, I don't quite understand what is going on inside the
recursion within the `cond' expression. There seem to be several way
how the recursion may terminate, and I don't see which of them yields
the obnoxious '#f". The definition of container-env-get looks
suspicious:
(define (container-env-get m key)
(let ((c (assq key (slot-ref m 'env))))
(and (pair? c) (cadr c))))
So if (slot-ref subsections 'env) evaluates to an association list
that holds no key equal to 'footnote-env, or the associated value's
car is #f, the whole `cond' block returns #f and can't be passed to
`reverse'.
And the definition of the section markup reads:
(define-markup (section :rest
opts
:key
(ident #f) (class "section")
title info-node (file #f) (toc #t) (number
#t))
(new container
(markup 'section)
(ident (or ident (symbol->string (gensym "section"))))
(class class)
(loc &invocation-location)
(required-options '(:title :toc :file :toc :number))
(options `((:number ,(section-number number 'section))
(:toc ,toc)
,@(the-options opts :ident :class)))
(body (the-body opts))
(env (if file
(list (list 'subsection-counter 0) (list
'subsection-env '())
(list 'footnote-counter 0) (list 'footnote-env
'()))
(list (list 'subsection-counter 0) (list
'subsection-env '()))))))
So unless :file is #t, the env slot does not contain a 'footnote-env key.
The forgotten footnotes in sample code like
(document (chapter (footnote "foo"))(chapter (footnote "bar")))
are easier to explain, I guess. The `else' clause in the `cond' block
ignores the variable `footnotes' completely, and thus any already
accumulated footnotes are forgotten. Maybe it should read
(else (append (container-env-get subsections 'footnote-env) footnotes))
instead?
greetings,
Klaus Schilling
- [skribilo-users] (no subject),
Klaus Schilling <=