Unfortunately in this case the result for

◊(->html
  ◊ac:link{
 ◊ri:attachment[#:ri:filename "atlassian_logo.gif"]{
  ◊ac:plain-text-link-body{◊as-cdata{Text with <> }}}})

is
<ac:link><ri:attachment 
ri:filename="atlassian_logo.gif"><ac:plain-text-link-body>&lt;![CDATA[Text 
with &lt;&gt; ]]&gt;</ac:plain-text-link-body></ri:attachment></ac:link>

but thanks for you example, looking at this, the following idea came me

#lang pollen/pre
◊(require pollen/template/html)
◊(require racket/string)

◊(define (cdata-norm s)
   (regexp-replace* #rx"\\<cdata\\>(.*)\\</cdata\\>" s
     (lambda (all one)
       (string-append "<![CDATA["
         (string-replace
           (string-replace
             (string-replace one
               "&lt;" "<")
               "&gt;" ">")
               "&amp;" "&") "]]>" ))))

◊(cdata-norm (->html
  ◊ac:link{
 ◊ri:attachment[#:ri:filename "atlassian_logo.gif"]{
  ◊ac:plain-text-link-body{◊cdata{Text with <> }}}}))

result

<ac:link><ri:attachment 
ri:filename="atlassian_logo.gif"><ac:plain-text-link-body><![CDATA[Text 
with <> ]]></ac:plain-text-link-body></ri:attachment></ac:link>



понедельник, 20 ноября 2017 г., 20:42:05 UTC+3 пользователь Matthew 
Butterick написал:
>
>
> On Nov 19, 2017, at 10:49 PM, [email protected] <javascript:> wrote:
>
> I need to export in "confluence storage format" - 
> https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html#ConfluenceStorageFormat-Links
>
>
>
> I just pushed an update that will handle "<![CDATA[···]]" strings 
> correctly. 
>
> Input (putting all the parts together in one file for demonstration 
> purposes):
>
> ;;;
>
> #lang pollen/pre
> ◊(require pollen/template/html)
>
> ◊(define (as-cdata string)
>    (string-append "<![CDATA[" string "]]>"))
>
> ◊(->html
>   ◊ac:link{
>  ◊ri:attachment[#:ri:filename "atlassian_logo.gif"]{
>   ◊ac:plain-text-link-body{◊as-cdata{Link to a Confluence Attachment}}}})
>
> ;;;
>
> Result:
>
> <ac:link><ri:attachment 
> ri:filename="atlassian_logo.gif"><ac:plain-text-link-body><![CDATA[Link to 
> a Confluence 
> Attachment]]></ac:plain-text-link-body></ri:attachment></ac:link>
>
> * * *
>
> Supernerds might point out that this fix is a bit of a cheat: The official 
> grammar for X-expressions includes the `cdata` structure type. [1] But 
> Pollen still does not support this `cdata` structure directly.
>
> The problem is that the `cdata` is an outlier in the grammar: it's the 
> only element that can't be serialized (meaning, written to a string in a 
> way that allows it to be reconstituted later). Pollen relies heavily on 
> disk caching. So the problem is that these `cdata` objects can't be cached 
> to disk. CDATA strings, however, can be.
>
> I'm not sure what the deeper fix would be — probably to update Racket's 
> `xml` module so that its structures, including `cdata`, are serializable.
>
>
> [1] 
> https://docs.racket-lang.org/xml/index.html?q=xexpr%3F#%28def._%28%28lib._xml%2Fprivate%2Fxexpr-core..rkt%29._xexpr~3f%29%29
>  
> <https://docs.racket-lang.org/xml/index.html?q=xexpr?#(def._((lib._xml/private/xexpr-core..rkt)._xexpr~3f))>
>

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