[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: |
Mon, 11 Jul 2016 08:48:42 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sun, Jul 10, 2016 at 09:58:49PM +0200, Jakub Jankiewicz 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
> "hello")</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
Ahhh... the HTML <script> tag. This one sticks out like a sore thumb :-)
Note that embedded Javascript can be... interesting. How would you parse
this:
<script type="text/javascript>
var kidding="the end of </script>";
# the above is just kidding
</script>
The html parser would have to parse the embedded script to grok that the
first close tag is just fake.
Strictly one has to quote (at least the '<') whithin the <script>, better
to quote all the (five?) magic XML entities. So the generated code above
seems OK. The client (aka browser) is supposed to unescape the text before
handing it over to the script machinery. So if it doesn't, yo'd have to
look there.
That said, you could try the XHTML trick and wrap the script in a CDATA
section. See e.g. [1], under "Differences Between HTML and XHTML" for
an example.
[1] http://www.w3schools.com/tags/tag_script.asp
regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iEYEARECAAYFAleDQUoACgkQBcgs9XrR2kbAswCfSpow0DUWEYOQL6NLXrncVYCW
AuAAnjeB8UdIkTfiGTARon4O21KFU5Jx
=WlJT
-----END PGP SIGNATURE-----
- How to render raw data using sxml?, Jakub Jankiewicz, 2016/07/10
- Re: How to render raw data using sxml?,
tomas <=
- Re: How to render raw data using sxml?, Amirouche Boubekki, 2016/07/11
- Re: How to render raw data using sxml?, Jakub Jankiewicz, 2016/07/12
- Re: How to render raw data using sxml?, Jakub Jankiewicz, 2016/07/12
- Re: How to render raw data using sxml?, tomas, 2016/07/13
- Re: How to render raw data using sxml?, Andy Wingo, 2016/07/14
- Re: How to render raw data using sxml?, tomas, 2016/07/14
- Re: How to render raw data using sxml?, Matt Wette, 2016/07/14
- Re: How to render raw data using sxml?, tomas, 2016/07/14
- Re: How to render raw data using sxml?, Amirouche Boubekki, 2016/07/15
- Re: How to render raw data using sxml?, Matt Wette, 2016/07/15