On Aug 1, 2016, at 10:57 AM, Chris Forster <[email protected]> wrote:
> I have written the following Pollen code to create such links:
>
> (txexpr 'a `((href ,(string-append "#fn" (number->string footnote-number))))
> `(sup ,(number->string footnote-number)))
>
>
> Everything is correct here except the sup produces not <sup>, but ⊃.
>
The third argument to the `txexpr` function is a list of txexpr elements, which
are attached as the tail of the txexpr. The problem here is that your third
argument:
> `(sup ,(number->string footnote-number))
Produces
'(sup 42)
Which the `txexpr` function understands to be a list of two txexpr elements (=
a symbol followed by a number). But you want it to behave as a single txexpr.
So you need to wrap it in another list like so:
#lang racket
(require txexpr)
(define footnote-number 42)
(txexpr 'a `((href ,(string-append "#fn" (number->string footnote-number))))
(list `(sup ,(number->string footnote-number))))
If you find this annoying to keep track of, you can just make the txexpr as one
quasiquoted expression:
#lang racket
(require txexpr)
(define footnote-number 42)
`(a ((href ,(string-append "#fn" (number->string footnote-number)))) (sup
,(number->string footnote-number)))
FWIW this ambiguity is unavoidable — I touch on it in the docs for `decode` [1].
That said, I don't think it would hurt to add a `txexpr*` function that allows
you to avoid the list-wrapping fandango (similar to how `list*` behaves
compared to `list`)
[1]
http://docs.racket-lang.org/pollen/Decode.html#%28def._%28%28lib._pollen%2Fdecode..rkt%29._decode%29%29
--
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.