> Correction: `(length fn-names)` should be `(length (member name 
fn-names))` to handle the possibility of multiple references to the same 
footnote. 

I made a few more changes to fully handle the multiple references to the 
same footnote case. The missing footnote case is also easily handled at the 
point of the call to hash-ref.

(define fn-names null)
(define (fn name-in)
  (define name (format "~a" name-in))
  (set! fn-names (cons name fn-names))
  `(sup (a ((href ,(string-append "#" (fnref-id name)))
            (id ,(string-append (fn-id name) (number->string (count (curry 
string=? name) fn-names)))))
           ,(format "(~a)" (+ 1 (index-of (remove-duplicates (reverse 
fn-names)) name))))))

(define fndefs (make-hash))
(define (fndef name . xs) (hash-set! fndefs (format "~a" name) xs))

(define (footnote-block)
  (define note-items
    (for/list ([fn-name (in-list (remove-duplicates (reverse fn-names)))])
              `(li ((id ,(fnref-id fn-name)))
                   ,@(append
                      (or (hash-ref fndefs fn-name #f) '((i "Missing.")))
                      (for/list ([fref-num (in-range (count (curry string=? 
fn-name) fn-names))])
                                `(a ((href ,(string-append "#" (fn-id 
fn-name) (format "~a" (+ 1 fref-num))))) "↩"))))))
  `(section ((class "footnotes")) (ol ,@note-items)))

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to