guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to render raw data using sxml?


From: tomas
Subject: Re: How to render raw data using sxml?
Date: Wed, 13 Jul 2016 15:36:20 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, Jul 13, 2016 at 05:28:02AM -0700, Matt Wette wrote:
> 
> > On Jul 10, 2016, at 12:58 PM, Jakub Jankiewicz <address@hidden> wrote:
> > 
> > Hi,
> > 
> > I want to render scheme code inside script tag to be executed by biwascheme
> > in the browser so I've try to create simple page using sxml (cgi script):
> > 
> > (display "Content-Type: text/html")
> > (newline)
> > (newline)
> > (display "<!DOCTYPE html>")
> > (newline)
> > (sxml->xml `(html
> >              (head
> >                 (title "BiwaScheme test")
> >                 (script (@ (src "biwascheme-min.js")) "(display 
> > \"hello\")"))
> >              (body (p "BiwaScheme test"))))
> > 
> > but the output was:
> > 
> > <!DOCTYPE html>
> > <html><head><title>BiwaScheme test</title><script
> > src="biwascheme-min.js">(display
> > &quot;hello&quot;)</script></head><body><p>BiwaScheme test</p></body></html>
> > 
> > which is invalid scheme code. I've also try this:
> > 
> > (script (@ (src "biwascheme-min.js")) "(display " #\" "hello" #\" ")")
> > 
> > but got the same result. How can I display raw data using sxml->xml
> 
> I googled “sxml CDATA” and found that Chicken Scheme has a
> “sxml-serialize” procedure that takes an optional keyword
> argument cdata-section-elements which is a list of elements
> which should have contents serialized to a CDATA section.
> It seems like if sxml->xml had something like that you might
> have a solution.
> Does <script><![CDATA[(display “hello”)]]></script> work on HTML?

As far as I understand, this is the way to do it in XHTML. In
HTML it's at least... uncommon (I don't know whether it's
officially sanctioned, but I guess the browsers will cope,
somehow, as they always do :-)

Ah, no. It's even funnier, see [1], [2]

TL;DR: HTML doesn't know about CDATA. But if you want your
thingie to parse as HTML *and* to validate as XML, you can
do this:

  <script type="text/javascript">
    //<![CDATA[
    document.write("<");
    //]]>
  </script>

Otherwise the javascript processor would get passed "<![CDATA[..."
and would freak out).

I am speechless. Someday, this rat's nest will become
sentient, and it will be ugly.

regards

[1] 
http://stackoverflow.com/questions/66837/when-is-a-cdata-section-necessary-within-a-script-tag
[2] http://stackoverflow.com/questions/7092236/what-is-cdata-in-html
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAleGQ9QACgkQBcgs9XrR2kag7wCfY2EqxFnQ6mFjyE5HIIhoz5M2
dq8AnRuB6WgNwMmcEJd0c+CaOPi4+fK8
=8777
-----END PGP SIGNATURE-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]