hickory
hickory copied to clipboard
Failed for handling entity reference HTML code
When parsing HTML using hickory, converting it to hiccup, and then converting it back to HTML, the entity reference for & is processed twice, resulting in inconsistent output. Is this behavior intended? In JavaScript, conversion is never performed twice, and the result remains consistent.
hickory/hiccup behaviour
(-> "<div>a&b</div>"
hickory.core/parse-fragment
first
hickory.core/as-hiccup
hiccup2.core/html
str)
;;=> "<div>a&amp;b</div>"
javascript
const div = document.createElement('div')
div.innerHTML = "<div>a&b</div>"
> '<div>a&b</div>'
div.innerHTML
> '<div>a&b</div>'
div.textContent
> 'a&b'
expected
(-> "<div>a&b</div>"
hickory.core/parse-fragment
first
hickory.core/as-hiccup
hiccup2.core/html
str)
;;=> "<div>a&b</div>"