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
Parsing encoding problem with .html() on <style> tag #1186
Comments
Work on a clone in order to avoid mutating the symbolicweb.core> (let [document (Jsoup/parse (str ""
"<html>"
" <head>"
" <style>.outer > .inner {background-color:white;}</style>"
" </head>"
" <body>"
" Example"
" </body>"
"</html>"))
style (.selectFirst document "style")]
(println (.toString (.html style (.html style))))
(println "\n###\n")
(println (.toString document)))
<style>.outer > .inner {background-color:white;}</style>
###
<html>
<head>
<style>.outer > .inner {background-color:white;}</style>
</head>
<body>
Example
</body>
</html>
nil
symbolicweb.core> ...when we use .clone, it is fixed: symbolicweb.core> (let [document (Jsoup/parse (str ""
"<html>"
" <head>"
" <style>.outer > .inner {background-color:white;}</style>"
" </head>"
" <body>"
" Example"
" </body>"
"</html>"))
style (.clone (.selectFirst document "style"))]
(println (.toString (.html style (.html style))))
(println "\n###\n")
(println (.toString document)))
<style>.outer > .inner {background-color:white;}</style>
###
<html>
<head>
<style>.outer > .inner {background-color:white;}</style>
</head>
<body>
Example
</body>
</html>
nil
symbolicweb.core> |
I have found the problem. Mutating STYLE element must not be done with Element.html() but with a DataNode I am sending a Pull Request with an example in form of test case |
Thank you @eolivelli that solved the problem. |
This was fixed with #1419 |
I have a problem parsing and then setting the <style> tag.
When I do .html() and then set back the string with .html(s) I get the HTML entity < that does not work correctly in CSS.
When I do:
I get:
But I'm expecting that the style tag preserve the > selector or it won't work correctly.
I'm expecting that the result HTML code is:
I would be happy to contribute to an eventual patch if you give me some hints.
The text was updated successfully, but these errors were encountered: