Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escaping ampersands in Blaze Html

I want to put an HTML entity (in particular, ©) into my document. However if I type it and feed it as a Text straight into a blaze combinator, the ampersand is html-escaped and comes out as literally © -- or rather, the HTML outputted is ©, which is kind of ironic.

(If I use blaze-from-html on HTML that contains ©, blaze-from-html turns it into the unicode copyright symbol "©", which works, but I'd still like to know if it was possible to access the lower-level HTML with blaze and type a literal html-source &.)

like image 775
Justin L. Avatar asked Oct 04 '22 09:10

Justin L.


1 Answers

If you are using the blaze Text.Blaze.Html.toHtml function, there is a corresponding preEscapedToHtml function that will not escape entities. Sample ghci session -

λ> renderHtml $ toHtml "©"
"©"
λ> renderHtml $ preEscapedToHtml "©"
"©"
like image 183
Anupam Jain Avatar answered Oct 10 '22 03:10

Anupam Jain