Forum
Displaying HTML entities in textareas
Hi,
Like some others, I want a slightly mental thing to happen when I type in an HTML entity into a textarea.
To explain, I am writing a blog post about HTML entities so would like to state what the code for any given entity is, for example &
. What happens with the textarea (in the admin) is that whilst I initially write &
as soon as it is saved, the browser will display the character &
instead. What I would like to happen is that my original text is preserved.
The output to the actual web page is correct, it’s how the textarea displays its content that isn’t quite how I would like it to be.
I have a workaround by escaping the entity (&), but I can only save the blog post once and cannot edit unless I copy and paste again from my source file.
I know it is possible to do things like
preg_replace(‘/&(\w+;)/‘, ‘&$1’, $text_in_textarea );
but as this sort of thing is handled by the perch/core
, I’m not sure what, if anything I can do.
I may be trying to have my cake and eat it with this, but some guidance would be helpful.
What options are you using on your template tag?
At the moment
but I have tried things like
html="true"
, and different editors.I would expect that to work. If that's not how it's working, then I'll need to see if we can change it without making a mess of everyone else's sites.