Re: [pollen] How to insert CDATA?

2017-11-21 Thread a . bezlepko
Thank you! That helped

raco pkg update --update-deps pollen




вторник, 21 ноября 2017 г., 0:02:41 UTC+3 пользователь Matthew Butterick 
написал:
>
>
> On Nov 20, 2017, at 12:39 PM, a.bez...@gmail.com  wrote:
>
> 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
>  ri:filename="atlassian_logo.gif">![CDATA[Text 
> with  ]]
>
>
> That's strange. Did you update your `pollen` like so?
>
> raco pkg update --update-deps pollen
>
>
> I get a different result:
>
> ; program
> #lang pollen/pre
> ◊(require pollen/template/html)
>
> ◊(define (as-cdata string)
>(string-append ""))
>
> ◊(->html
>   ◊ac:link{
>  ◊ri:attachment[#:ri:filename "atlassian_logo.gif"]{
>   ◊ac:plain-text-link-body{◊as-cdata{Text with <> )
>
>
>  result
>  ri:filename="atlassian_logo.gif">
>
>
>
>
>
> but thanks for you example, looking at this, the following idea came me
>
>
> Your code won't work on HTML blocks with more than one CDATA.
>

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


Re: [pollen] How to insert CDATA?

2017-11-20 Thread Matthew Butterick

> On Nov 20, 2017, at 12:39 PM, a.bezle...@gmail.com wrote:
> 
> 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
>  ri:filename="atlassian_logo.gif">![CDATA[Text 
> with  ]]

That's strange. Did you update your `pollen` like so?

raco pkg update --update-deps pollen

I get a different result:

; program
#lang pollen/pre
◊(require pollen/template/html)

◊(define (as-cdata string)
   (string-append ""))

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


 result






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

Your code won't work on HTML blocks with more than one CDATA.

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


Re: [pollen] How to insert CDATA?

2017-11-20 Thread Matthew Butterick

> On Nov 19, 2017, at 10:49 PM, a.bezle...@gmail.com 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 ""))

◊(->html
  ◊ac:link{
 ◊ri:attachment[#:ri:filename "atlassian_logo.gif"]{
  ◊ac:plain-text-link-body{◊as-cdata{Link to a Confluence Attachment)

;;;

Result:



* * *

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
 


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


Re: [pollen] How to insert CDATA?

2017-11-19 Thread a . bezlepko
Hi,

I need to export in "confluence storage format" - 
https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html#ConfluenceStorageFormat-Links

понедельник, 20 ноября 2017 г., 7:15:58 UTC+3 пользователь Matthew 
Butterick написал:
>
> BTW the `->html` function, consistent with the HTML spec, will 
> automatically treat `script` and `style` blocks as CDATA, so if that's what 
> you're aiming for, no special sorcery needed.
>
>
> On Nov 19, 2017, at 3:36 PM, Matthew Butterick  > wrote:
>
> Seems like it should work. Not sure why it isn't. I'll look into it.
>
>
> On Nov 19, 2017, at 1:10 PM, a.bez...@gmail.com  wrote:
>
>
>
> My plan_b.html.pm
> 
> #lang pollen
> ◊as-cdata{567}
> 
>
> My pollen.rkt
> 
> #lang racket/base
> (require pollen/tag)
> (require pollen/decode)
> (require txexpr)
> (require xml)
> (require racket/list)
> (provide (all-defined-out))
>
> (define (as-cdata string)
>   (cdata #f #f string))
> 
>
> My template.html
> 
> 
> ◊(->html ◊doc)
> 
> 
>
>
>
>

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


Re: [pollen] How to insert CDATA?

2017-11-19 Thread Matthew Butterick
BTW the `->html` function, consistent with the HTML spec, will automatically 
treat `script` and `style` blocks as CDATA, so if that's what you're aiming 
for, no special sorcery needed.


> On Nov 19, 2017, at 3:36 PM, Matthew Butterick  wrote:
> 
> Seems like it should work. Not sure why it isn't. I'll look into it.
> 
> 
>> On Nov 19, 2017, at 1:10 PM, a.bezle...@gmail.com 
>>  wrote:
>> 
>> 
>> 
>> My plan_b.html.pm
>> 
>> #lang pollen
>> ◊as-cdata{567}
>> 
>> 
>> My pollen.rkt
>> 
>> #lang racket/base
>> (require pollen/tag)
>> (require pollen/decode)
>> (require txexpr)
>> (require xml)
>> (require racket/list)
>> (provide (all-defined-out))
>> 
>> (define (as-cdata string)
>>   (cdata #f #f string))
>> 
>> 
>> My template.html
>> 
>> 
>> ◊(->html ◊doc)
>> 
>> 
> 

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


Re: [pollen] How to insert CDATA?

2017-11-19 Thread Matthew Butterick
Seems like it should work. Not sure why it isn't. I'll look into it.


> On Nov 19, 2017, at 1:10 PM, a.bezle...@gmail.com wrote:
> 
> 
> 
> My plan_b.html.pm
> 
> #lang pollen
> ◊as-cdata{567}
> 
> 
> My pollen.rkt
> 
> #lang racket/base
> (require pollen/tag)
> (require pollen/decode)
> (require txexpr)
> (require xml)
> (require racket/list)
> (provide (all-defined-out))
> 
> (define (as-cdata string)
>   (cdata #f #f string))
> 
> 
> My template.html
> 
> 
> ◊(->html ◊doc)
> 
> 

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


[pollen] How to insert CDATA?

2017-11-19 Thread a . bezlepko


My plan_b.html.pm

#lang pollen
◊as-cdata{567}


My pollen.rkt

#lang racket/base
(require pollen/tag)
(require pollen/decode)
(require txexpr)
(require xml)
(require racket/list)
(provide (all-defined-out))

(define (as-cdata string)
  (cdata #f #f string))


My template.html


◊(->html ◊doc)



Result

...>raco pollen render plan_b.html.pm

rendering plan_b.html.pm
rendering: /plan_b.html.pm as /plan_b.html

->html: contract violation
  expected: (or/c txexpr-element? txexpr-elements?)
  given: '(root #(struct:cdata #f #f "567") "\n" "\n")
  in: the 1st argument of
  (->*
   ((or/c txexpr-element? txexpr-elements?))
   (#:attrs
(or/c #f txexpr-attrs?)
#:splice
boolean?
#:splice?
boolean?
#:tag
(or/c #f txexpr-tag?))
   string?)
  contract from:
  /pollen/pollen/template/html.rkt
  blaming: top-level
   (assuming the contract is correct)
  at: /pollen/pollen/template/html.rkt:14.26

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