"Format and indent" command introduces javascript errors
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 22
- Joined: Tue Apr 08, 2008 1:41 pm
"Format and indent" command introduces javascript errors
Post by sampablokuper »
I'm having the difficulty that the "Format and indent" command sometimes alters javascript in a way that breaks the functionality of the code.
Suppose my document is something like this:
If I then use the "format and indent" command, the result is the following:
OK, the XHTML looks great now, but what about the javascript? Well, the deHashRegex regular expression has been corrupted. Because of the whitespace introduced between some its characters, it will no longer work in browsers. Essentially, oXygen's parser has confused a regular expression for a mathematical one, and has put spaces either side of the asterisk accordingly, and has placed a space after the closing parenthesis.
Does anyone have a solution to this, other than commenting out the javascript or putting it in a CDATA block (either of which would mean I wouldn't get syntax highlighting for the javascript any more)?
Many thanks,
Sam
Suppose my document is something like this:
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Foo</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"></meta>
</head>
<body>
<script type="text/javascript">
deHashRegex = /([\s\S]*?)#/g;
locNoHash = deHashRegex.exec(document.location);
</script>
<p>(Main body content.)</p>
</body>
</html>
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Foo</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"></meta>
</head>
<body>
<script type="text/javascript">
deHashRegex = /([\s\S] * ?) #/g;
locNoHash = deHashRegex.exec(document.location);</script>
<p>(Main body content.)</p>
</body>
</html>
Does anyone have a solution to this, other than commenting out the javascript or putting it in a CDATA block (either of which would mean I wouldn't get syntax highlighting for the javascript any more)?
Many thanks,
Sam
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: "Format and indent" command introduces javascript errors
Post by sorin_ristache »
Hello,
Thank you for reporting this problem. We will fix it in the next version of oXygen.
I think there is no other workaround. You should put the JavaScript code in a CDATA block.
Regards,
Sorin
Thank you for reporting this problem. We will fix it in the next version of oXygen.
I think there is no other workaround. You should put the JavaScript code in a CDATA block.
Regards,
Sorin
-
- Posts: 22
- Joined: Tue Apr 08, 2008 1:41 pm
Re: "Format and indent" command introduces javascript errors
Post by sampablokuper »
Dear Sorin,sorin wrote: Thank you for reporting this problem. We will fix it in the next version of oXygen.
I think there is no other workaround. You should put the JavaScript code in a CDATA block.
Thanks for the quick reply and the advice. I'll use CDATA for the time being.
All best,
Sam
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: "Format and indent" command introduces javascript errors
Post by sorin_ristache »
Hello,
Now you can disable the option Allow formatting embedded JavaScript from Options -> Preferences -> Editor -> Format -> JavaScript and the JavaScript embedded in an XML file will not be formatted anymore.
Regards,
Sorin
Now you can disable the option Allow formatting embedded JavaScript from Options -> Preferences -> Editor -> Format -> JavaScript and the JavaScript embedded in an XML file will not be formatted anymore.
Regards,
Sorin
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