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.
Hmmm, now it is working. Why?
Oh, just delete this question, sorry Matt.
posted by Grod at 6:38 PM on August 10, 2004
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 &. for the <textarea>
posted by holloway at 7:09 PM on August 10, 2004
posted by holloway at 7:09 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 "<" you can't just put the string "<" between the <textarea> tag, you'll need to put "&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 < and > (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 "&" 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 < and &rt; anymore)
posted by holloway at 10:15 PM on August 10, 2004
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 "<" you can't just put the string "<" between the <textarea> tag, you'll need to put "&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 < and > (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 "&" 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 < 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
posted by holloway at 10:18 PM on August 10, 2004
You are not logged in, either login or create an account to post comments
Question: When I use a a character code in a post, for example, &#8212; (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