> On Jan 22, 2018, at 4:38 PM, Joel Dueck <[email protected]> wrote:
>
> We’re getting heavy snow all day today here in Minneapolis, so I took the day
> off. I spent some of the down time writing up my approach for implementing
> footnotes in an upcoming project:
> https://thenotepad.org/posts/pollen-footnotes-approach.html
Thanks a lot for this Joel. I was drawn to your comment in the article:
"The output for footnotes (given my requirements) can’t very well be handled
within individual tag functions; it demands a top-down approach."
I was curious why this was necessarily so. I tried refactoring your footnote
mechanism into tag functions. (I left out the MD5 fingerprinting and the
blank-footnote requirement.) Result below. It seems to work with your samples.
Where does this approach break down?
;;;;;;;;;;;;;;;;;
#lang racket/base
(provide (all-defined-out))
(define (fn-id x) (string-append x "_fn"))
(define (fnref-id x) (string-append x "_fnref"))
(define fn-names null)
(define (fn name-in)
(define name (format "~a" name-in))
(set! fn-names (if (member name fn-names) fn-names (cons name fn-names)))
`(sup (a ((href ,(string-append "#" (fnref-id name)))
(id ,(fn-id name)))
,(format "(~a)" (length fn-names)))))
(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 (reverse fn-names))])
`(li ((id ,(fnref-id fn-name)))
,@(append
(hash-ref fndefs fn-name)
(list `(a ((href ,(string-append "#" (fn-id fn-name))))
"↩"))))))
`(section ((class "footnotes")) (ol ,@note-items)))
(define (root . elements)
`(root ,@elements ,(footnote-block)))
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.