The problem is that

@(define x "asd")

"asd"

"@|x|"

results in:

'(@
  "\"asd\""
  "\n"
  "\n"
  "\""
  "asd"
  "\"")

Since string-proc only provides one string to smart-quotes at a time,
smart-quotes can’t see the matching quotes for the latter asd, so no
replacement occurs.

To fix this, simply change

(define (root . elements)
      (txexpr '@ empty (decode-elements elements
            #:string-proc smart-quotes)))

to

(define (root . elements)
      (smart-quotes (txexpr '@ empty elements)))

which will make smart-quotes see the whole thing, so it can match quotes
across strings.

While it seems smart-quotes can handle txexpr, it doesn’t seem to be fully
supported (i.e., there are still unhandled cases). An alternative way in
case the above approach doesn’t work is to decode in two passes. The first
pass goes over elements and combine consecutive strings together. The
second pass uses your original decoder.

On Mon, Feb 18, 2019 at 1:53 AM alexis.dieu via Pollen <
[email protected]> wrote:

> Hello,
>
> I don't know if it's a bug, but *smart-quotes* doesn't seem to work when
> the quotes contains a variable instead of a text.
>
> *pollen.rkt*
> #lang racket
> (require pollen/decode txexpr)
> (provide (all-defined-out))
>
> (define (root . elements)
>       (txexpr '@ empty (decode-elements elements
>             #:string-proc smart-quotes)))
>
> *quotes-test.html.pm <http://quotes-test.html.pm>*
> #lang pollen/markup
>
> ◊(define greetings "Hello, world!")
> "◊|greetings|" ; "Hello, world!"
>
> *racket quotes-test.html.pm <http://quotes-test.html.pm>*
> '(@ "\"" "Hello, world!" "\" ; “Hello, world!”" "\n")%
>
> Is there a way to fix this?
>
> --
> 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.
>

-- 
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.

Reply via email to