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

Escaping of Tag Content #12

Closed
semperos opened this issue May 25, 2012 · 3 comments
Closed

Escaping of Tag Content #12

semperos opened this issue May 25, 2012 · 3 comments

Comments

@semperos
Copy link

I believe in Hiccup the content portion of tags is not HTML-escaped by default. In Crate, when I provide a string with raw HTML inside it, it appears that the Google methods used by Crate createTextNode and/or setTextContent do escape the content string.

I need to be able to pass raw HTML strings as the content to elements. How can I go about this using Crate?

@zussitarze
Copy link

This isn't a bug in crate. The google-closure createTextNode is not escaping the text either, it's a plain wrapper over the Document createTextNode(). The latter method does not interpret or parse it's input, which is why HTML entity characters are printed literally. What to do? Since this question was posted 5 months ago, I gather you've found a solution. In any case, if you're working with UTF-8 encoded documents, send the equivalent unicode notation for the HTML entity,

e.g. &ldquo -> \u201C ...

@bmaddy
Copy link
Contributor

bmaddy commented Dec 31, 2012

This threw me too. It's because crate returns dom nodes instead of strings like hiccup. It uses createTextNode to do this. Conveniently, it accepts dom nodes as node content so you can do stuff like this:

(crate/html [:div (.htmlToDocumentFragment goog.dom "<span>foo</span><strong>bar</strong>")])
=> <div><span>foo</span><strong>bar</strong></div>

@bmaddy bmaddy mentioned this issue Dec 31, 2012
@semperos
Copy link
Author

Haven't touched or looked at this in a long time, closing.

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

No branches or pull requests

3 participants