Em dash question August 10, 2004 6:32 PM   Subscribe

Question: When I use a a character code in a post, for example, — (em dash) it turns into the character when I press "preview", if I forget to replace the actual character with it's code what appears in my comment is unpredictable.
posted by Grod to Bugs at 6:32 PM (8 comments total)

SEE! When I formatted the question it looked like this:
Question: When I use a a character code in a post, for example, &#8212&#059; (em dash) it turns into the character when I press "preview", if I forget to replace the actual character with it's code what appears in my comment is unpredictable.
When I previewed it, it looked like this (which is how I wanted it to look):
Question: When I use a a character code in a post, for example, — (em dash) it turns into the character when I press "preview", if I forget to replace the actual character with it's code what appears in my comment is unpredictable.
And when I clicked post it came out with an actual em dash.
Why?
posted by Grod at 6:37 PM on August 10, 2004



posted by Grod at 6:37 PM on August 10, 2004


Hmmm, now it is working. Why?
Oh, just delete this question, sorry Matt.
posted by Grod at 6:38 PM on August 10, 2004


No, it's still broken. Matt needs to reencode all & as &amp;. for the <textarea>
posted by holloway at 7:09 PM on August 10, 2004


Also discussed here.

And here.
posted by filmgoerjuan at 9:08 PM on August 10, 2004


The code that refills the <textarea> with what was just previewed is buggy. It passes back the text/utf-8-bytes as is without reencoding it as it should.

This is because all browsers display the content between <textarea> not as raw text, but as parsed for HTML entities. If you want a <textarea> to display the string "&lt;" you can't just put the string "&lt;" between the <textarea> tag, you'll need to put "&amp;lt;".

When I say that Mefi isn't reencoding <textarea>s as it should that's not quite true because it does recode the strings &lt; and &gt; (you can preview with those strings as many times as you want) just not entities in general.

The fix is to changing the string "&" to "&amp;" for the <textarea> (and be careful not to encode it twice, because now that it's reencoding the ampersands correctly there's no need to reencode &lt; and &rt; anymore)
posted by holloway at 10:15 PM on August 10, 2004


Just posting to say that all those entities are as I wanted them, so you could do that string replacement if you want entities to work through previews :)
posted by holloway at 10:18 PM on August 10, 2004


Think outside the box, Grod.
posted by me3dia at 12:24 PM on August 11, 2004


« Older Is it OK to have one of the links be a self link...   |   Watching Threads Newer »

You are not logged in, either login or create an account to post comments