Forum Bugs

Inline Javascript

clod81
Hi,
I tried to put inline javascript with some html formatting tags.
The JS works perfectly on the browser, but prince says that the document is not well formatted.
If I load the same JS from a url, it works fine.
mikeday
Currently Prince expected valid HTML4, in which special characters like < and & must be escaped as entities even if they occur in a <script> element.

However, we are working on a new HTML5 parser that is more consistent with browser behaviour. You can enable this by passing "-i html5" on the command-line. It is still experimental, and only UTF-8 encoded documents are supported at the present time. We plan to switch to this new parser with the next release of Prince.
clod81
mikeday wrote:
Currently Prince expected valid HTML4, in which special characters like < and & must be escaped as entities even if they occur in a <script> element.

However, we are working on a new HTML5 parser that is more consistent with browser behaviour. You can enable this by passing "-i html5" on the command-line. It is still experimental, and only UTF-8 encoded documents are supported at the present time. We plan to switch to this new parser with the next release of Prince.



Thanks for the answer.
I'm currently trying out using docraptor, do you know if I can pass this option?
mikeday
Perhaps not, given that it is still experimental. You could try escaping characters that cause errors, eg. replace < with &lt; However, it may be simpler and more reliable to just use an external script file.
clod81
mikeday wrote:
Perhaps not, given that it is still experimental. You could try escaping characters that cause errors, eg. replace < with &lt; However, it may be simpler and more reliable to just use an external script file.


ok I'll go with the external option at the moment.
It can't be escapes, because it needs to be rendered as html on the page (ex: highcharts formatting options)
mikeday
We have now released Prince 9, which has a new HTML parser that correctly supports special characters like < inside <script> elements.