[xwiki-devs] Javascript in {{html}} or {{xhtml}} blocks in syntax 2.0
Hello, I realize that entering the following in a wiki document using syntax xwiki/2.0 : {{html}} <script type="text/javascript"> //<![CDATA[ alert("Hello, World") // ]]> </script> {{/html}} Results in html as : <!--startmacro:html|-||-| <script type="text/javascript"> //<![CDATA[ alert("Hello, World") // ]]> </script> --><!--stopmacro--> So the script tag is not rendered at all, thus the javascript not interpreted. Is this expected ? Is there a way to embed JS in a html block ? Regards, Jerome.
Hi Jerome, I've tested it and the problem is that if you use the HTML macro it'll perform some cleanup and it seems we have some code that strips scripts in cleanup. This is obviously wrong. For now you can use the xhtml macro and it should work fine. Note that it's always better to use the xhtml macro if you produce valid XHTML (which you should) since it improves performances (there's no cleanup to do). Thanks -Vincent On Oct 28, 2008, at 10:17 AM, Jerome Velociter wrote:
Hello,
I realize that entering the following in a wiki document using syntax xwiki/2.0 :
{{html}} <script type="text/javascript"> //<![CDATA[ alert("Hello, World") // ]]> </script> {{/html}}
Results in html as :
<!--startmacro:html|-||-| <script type="text/javascript"> //<![CDATA[ alert("Hello, World") // ]]> </script> --><!--stopmacro-->
So the script tag is not rendered at all, thus the javascript not interpreted. Is this expected ? Is there a way to embed JS in a html block ?
Regards, Jerome.
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
ok I've fixed it by removing the cleaning and I've committed. However I'm getting some errors now which I'm looking into: org.jdom.IllegalDataException: The data "<![CDATA[ alert("Hello, World") // ]]> " is not legal for a JDOM CDATA section: CDATA cannot internally contain a CDATA ending delimiter (]]>). at org.jdom.CDATA.setText(CDATA.java:121) Thanks -Vincent On Oct 28, 2008, at 10:35 AM, Vincent Massol wrote:
Hi Jerome,
I've tested it and the problem is that if you use the HTML macro it'll perform some cleanup and it seems we have some code that strips scripts in cleanup. This is obviously wrong.
For now you can use the xhtml macro and it should work fine. Note that it's always better to use the xhtml macro if you produce valid XHTML (which you should) since it improves performances (there's no cleanup to do).
Thanks -Vincent
On Oct 28, 2008, at 10:17 AM, Jerome Velociter wrote:
Hello,
I realize that entering the following in a wiki document using syntax xwiki/2.0 :
{{html}} <script type="text/javascript"> //<![CDATA[ alert("Hello, World") // ]]> </script> {{/html}}
Results in html as :
<!--startmacro:html|-||-| <script type="text/javascript"> //<![CDATA[ alert("Hello, World") // ]]> </script> --><!--stopmacro-->
So the script tag is not rendered at all, thus the javascript not interpreted. Is this expected ? Is there a way to embed JS in a html block ?
Regards, Jerome.
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Thanks Vincent, I'm getting closer to it. I tried the following : {{xhtml}} <script type="text/javascript"> //<![CDATA[ alert("Hello, World") //]]> </script> {{/xhtml}} However, it is rendered as <!--startmacro:xhtml|-||-| <script type="text/javascript"> //<![CDATA[ alert("Hello, World") //]]> </script> --><script type="text/javascript"><em><br/>alert("Hello, World")<br/></em></script><!--stopmacro--> So I understand I should use a Verbatim block for the // and line returns not to be interpreted. I tried : {{xhtml}} {{{ <script type="text/javascript"> //<![CDATA[ alert("Hello, World") //]]> </script> }}} {{/xhtml}} But I get the following exception when viewing : http://rafb.net/p/NMEsjt96.html Regards, Jerome. Vincent Massol wrote:
Hi Jerome,
I've tested it and the problem is that if you use the HTML macro it'll perform some cleanup and it seems we have some code that strips scripts in cleanup. This is obviously wrong.
For now you can use the xhtml macro and it should work fine. Note that it's always better to use the xhtml macro if you produce valid XHTML (which you should) since it improves performances (there's no cleanup to do).
Thanks -Vincent
On Oct 28, 2008, at 10:17 AM, Jerome Velociter wrote:
Hello,
I realize that entering the following in a wiki document using syntax xwiki/2.0 :
{{html}} <script type="text/javascript"> //<![CDATA[ alert("Hello, World") // ]]> </script> {{/html}}
Results in html as :
<!--startmacro:html|-||-| <script type="text/javascript"> //<![CDATA[ alert("Hello, World") // ]]> </script> --><!--stopmacro-->
So the script tag is not rendered at all, thus the javascript not interpreted. Is this expected ? Is there a way to embed JS in a html block ?
Regards, Jerome.
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
By default the XHTML macro understands wiki syntax. To prevent that use: {{xhtml escapeWikiSyntax="true"}} However I see that it generates: <!--startmacro:xhtml|-|escapeWikiSyntax="true"|-| <script type="text/javascript"> //<![CDATA[ alert("Hello, World") // ]]> </script> --><script type="text/javascript"> // alert("Hello, World") // </script><!--stopmacro--> As you can see the CDATA have been removed which is wrong. I need to find out why they were removed. Thanks -Vincent On Oct 28, 2008, at 10:49 AM, Jerome Velociter wrote:
Thanks Vincent,
I'm getting closer to it. I tried the following :
{{xhtml}} <script type="text/javascript"> //<![CDATA[ alert("Hello, World") //]]> </script> {{/xhtml}}
However, it is rendered as
<!--startmacro:xhtml|-||-| <script type="text/javascript"> //<![CDATA[ alert("Hello, World") //]]> </script> --><script type="text/javascript"><em><br/>alert("Hello, World")<br/></em></script><!--stopmacro-->
So I understand I should use a Verbatim block for the // and line returns not to be interpreted.
I tried : {{xhtml}} {{{ <script type="text/javascript"> //<![CDATA[ alert("Hello, World") //]]> </script> }}} {{/xhtml}}
But I get the following exception when viewing : http://rafb.net/p/NMEsjt96.html
Regards, Jerome.
Vincent Massol wrote:
Hi Jerome,
I've tested it and the problem is that if you use the HTML macro it'll perform some cleanup and it seems we have some code that strips scripts in cleanup. This is obviously wrong.
For now you can use the xhtml macro and it should work fine. Note that it's always better to use the xhtml macro if you produce valid XHTML (which you should) since it improves performances (there's no cleanup to do).
Thanks -Vincent
On Oct 28, 2008, at 10:17 AM, Jerome Velociter wrote:
Hello,
I realize that entering the following in a wiki document using syntax xwiki/2.0 :
{{html}} <script type="text/javascript"> //<![CDATA[ alert("Hello, World") // ]]> </script> {{/html}}
Results in html as :
<!--startmacro:html|-||-| <script type="text/javascript"> //<![CDATA[ alert("Hello, World") // ]]> </script> --><!--stopmacro-->
So the script tag is not rendered at all, thus the javascript not interpreted. Is this expected ? Is there a way to embed JS in a html block ?
Regards, Jerome.
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
participants (2)
-
Jerome Velociter -
Vincent Massol