Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to insert raw content into script tag #83

Closed
abendt opened this issue Apr 25, 2018 · 5 comments
Closed

unable to insert raw content into script tag #83

abendt opened this issue Apr 25, 2018 · 5 comments

Comments

@abendt
Copy link

abendt commented Apr 25, 2018

the documentation (https://github.com/kotlin/kotlinx.html/wiki/Style-and-script-tags) says that it should be possible to insert raw content into a script tag.

This does not seem to work if I'm using the createHTMLDocument builder as then the inserted "raw" content needs to be valid XML. The example below causes a SAXParseException.

val html = createHTMLDocument().body {
            script(type = ScriptType.textJScript) {
                unsafe {
                    raw("""
                        function my() {return 1;}
                        """)
                }
            }
        }.serialize(true)

Is this intended?

I also setup a sample project to demonstrate the issue: https://github.com/abendt/kotlin-html-jscript/blob/master/src/test/kotlin/HtmlScriptTest.kt

@cy6erGn0m
Copy link
Contributor

Have you tried to wrap your script with // <!-- and // -->. It's quite old trick that could help to workaround the issue

@cy6erGn0m
Copy link
Contributor

Unfortunatetly there are limitations for unsafe raw content in DOM mode. This particular case need to be fixed somehow.

@abendt
Copy link
Author

abendt commented May 3, 2018

we tried to wrap the script with comments with no success (see https://github.com/abendt/kotlin-html-jscript/blob/master/src/test/kotlin/HtmlScriptTest.kt)

Our current workaround is to use the Streaming/String based builders.

@cy6erGn0m
Copy link
Contributor

Fixed in 0.6.10

@abendt
Copy link
Author

abendt commented May 4, 2018

yes, can confirm.

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants