webhelp.head.script converts &,<,> to & < >
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 167
- Joined: Tue Mar 06, 2018 1:34 am
webhelp.head.script converts &,<,> to & < >
I'm using Oxygen 20 classic webhelp.
My company has asked me to add a widget from a customer support company called ZenDesk. The widget is javascript and looks like this (I've replaced my company name with "company"):
<!-- Start of company Zendesk Widget script -->
<script>/*<![CDATA[*/window.zEmbed||function(e,n){var t,o,d,s,i,a=[],r=document.createElement("iframe");window.zEmbed=function(){a.push(arguments)},window.zE=window.zE||window.zEmbed,r.src="javascript:false",r.title="",r.role="presentation",(r.frameElement||r).style.cssText="display: none",d=document.getElementsByTagName("script"),d=d[d.length-1],d.parentNode.insertBefore(r,d),s=r.contentWindow,i=s.document;try{o=i}catch(e){t=document.domain,r.src='javascript:var d=document.open();d.domain="'+t+'";void(0);',o=i}o.open()._l=function(){var e=this.createElement("script");t&&(this.domain=t),e.id="js-iframe-async",e.src="https://assets.zendesk.com/embeddable_f ... his.t=+new Date,this.zendeskHost="company.zendesk.com",this.zEQueue=a,this.body.appendChild(e)},o.write('<body onload="document._l();">'),o.close()}("https://assets.zendesk.com/embeddable_f ... endesk.com");
/*]]>*/</script>
<!-- End of company Zendesk Widget script -->
I tried embedding this script directly into an HTML file that Oxygen generates, and it works - a little "Support" bubble appears on the bottom right. To automatically add this to all my output HTML files, I copied the script to a file and pointed to it from my transformation scenario using the webhelp.head.script parameter.
It didn't work...and it seems like the reason is that it converts these characters:
& --> &
< --> <
> --> >
For some reason, this causes the widget to not work. When I go into one of the generated HTML files and replace the "&", "<", and ">" with the original characters, then it works fine.
Is there a way to have Oxygen *not* convert these characters?
I tried a little javascript test to see if those character replacements interfere with normal Javascript, and it seems like they do:
=== This outputs "YES" ===
<html>
<head>
<script type="text/javascript">
if (1==1 && 2==2) {
document.write('YES');
}
</script>
</head>
</html>
=== This outputs nothing ===
<html>
<head>
<script type="text/javascript">
if (1==1 && 2==2) {
document.write('YES');
}
</script>
</head>
</html><html>
<head>
<script type="text/javascript">
if (1==1 && 2==2) {
document.write('YES');
}
</script>
</head>
</html>
My company has asked me to add a widget from a customer support company called ZenDesk. The widget is javascript and looks like this (I've replaced my company name with "company"):
<!-- Start of company Zendesk Widget script -->
<script>/*<![CDATA[*/window.zEmbed||function(e,n){var t,o,d,s,i,a=[],r=document.createElement("iframe");window.zEmbed=function(){a.push(arguments)},window.zE=window.zE||window.zEmbed,r.src="javascript:false",r.title="",r.role="presentation",(r.frameElement||r).style.cssText="display: none",d=document.getElementsByTagName("script"),d=d[d.length-1],d.parentNode.insertBefore(r,d),s=r.contentWindow,i=s.document;try{o=i}catch(e){t=document.domain,r.src='javascript:var d=document.open();d.domain="'+t+'";void(0);',o=i}o.open()._l=function(){var e=this.createElement("script");t&&(this.domain=t),e.id="js-iframe-async",e.src="https://assets.zendesk.com/embeddable_f ... his.t=+new Date,this.zendeskHost="company.zendesk.com",this.zEQueue=a,this.body.appendChild(e)},o.write('<body onload="document._l();">'),o.close()}("https://assets.zendesk.com/embeddable_f ... endesk.com");
/*]]>*/</script>
<!-- End of company Zendesk Widget script -->
I tried embedding this script directly into an HTML file that Oxygen generates, and it works - a little "Support" bubble appears on the bottom right. To automatically add this to all my output HTML files, I copied the script to a file and pointed to it from my transformation scenario using the webhelp.head.script parameter.
It didn't work...and it seems like the reason is that it converts these characters:
& --> &
< --> <
> --> >
For some reason, this causes the widget to not work. When I go into one of the generated HTML files and replace the "&", "<", and ">" with the original characters, then it works fine.
Is there a way to have Oxygen *not* convert these characters?
I tried a little javascript test to see if those character replacements interfere with normal Javascript, and it seems like they do:
=== This outputs "YES" ===
<html>
<head>
<script type="text/javascript">
if (1==1 && 2==2) {
document.write('YES');
}
</script>
</head>
</html>
=== This outputs nothing ===
<html>
<head>
<script type="text/javascript">
if (1==1 && 2==2) {
document.write('YES');
}
</script>
</head>
</html><html>
<head>
<script type="text/javascript">
if (1==1 && 2==2) {
document.write('YES');
}
</script>
</head>
</html>
Last edited by mdslup on Thu Apr 26, 2018 9:12 pm, edited 1 time in total.
-
- Site Admin
- Posts: 275
- Joined: Thu Dec 24, 2009 11:21 am
Re: webhelp.head.script converts &,<,> to & < >
Hello,
You should place your JS content inside an XML comment (<!-- -->):
Regards,
Alin
You should place your JS content inside an XML comment (<!-- -->):
Code: Select all
<script type="text/javascript">
<!--
if (1==1 && 2==2) {
document.write('YES');
}
//-->
</script>
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Site Admin
- Posts: 275
- Joined: Thu Dec 24, 2009 11:21 am
Re: webhelp.head.script converts &,<,> to & < >
Hello,
There is no predefined option (parameter) that would allow you to instruct the WebHelp plugin to not escape the XML special characters (&, <, >, etc.).
The content of the file referenced using the "webhelp.head.script" parameter is included in the output HTML files via XSLT. When serializing the output, the XSLT processor expands the XML special characters into their corresponding character entities.
To avoid this behavior it is recommended to wrap the inline JavaScript (or CSS) fragments in an XML comment. The XSLT processor will not escape the special characters within the XML comment content.
Regards,
Alin
There is no predefined option (parameter) that would allow you to instruct the WebHelp plugin to not escape the XML special characters (&, <, >, etc.).
The content of the file referenced using the "webhelp.head.script" parameter is included in the output HTML files via XSLT. When serializing the output, the XSLT processor expands the XML special characters into their corresponding character entities.
To avoid this behavior it is recommended to wrap the inline JavaScript (or CSS) fragments in an XML comment. The XSLT processor will not escape the special characters within the XML comment content.
Regards,
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 167
- Joined: Tue Mar 06, 2018 1:34 am
Re: webhelp.head.script converts &,<,> to & < >
I figured this out! The way to do this is to have the file that is pointed to by webhelp.head.script include a file reference, not the script inline. Then add the file that contains the script to the resources folder using webhelp.custom.resources.
It's the second bullet point in item #1 of this link: https://www.oxygenxml.com/doc/versions/ ... assic.html
It's the second bullet point in item #1 of this link: https://www.oxygenxml.com/doc/versions/ ... assic.html
Return to “DITA (Editing and Publishing DITA Content)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service