blocks to the clipboard correctly?We\'ve noticed that IE7 has an odd behavor with code blocks posted on Stack Overflow. For example, this little code block:
public PageSizer(string href, int inde
Here's the issue:
Your code colorization script replaces line breaks with
tags. When copying/pasting, IE7 apparently doesn't translate the
tag into a linebreak like it does for the screen.
In other words, your code becomes this:
public PageSizer(string href, int index)
{
HRef = href;
PageIndex = index;
}
But you want it to become this:
public PageSizer(string href, int index)
{
HRef = href;
PageIndex = index;
}
In the latest version of prettify.js on Google Code, the line responsible is line 1001 (part of recombineTagsAndDecorations):
html.push(htmlChunk.replace(newlineRe, '
'));
Edited, based on the comments:
For IE7, this is what the line should probably be changed to:
html.push(htmlChunk.replace(newlineRe, '\n'));
(Assuming newlineRe is a placeholder).
This fix also holds up in Chrome, and FFX3... I'm not sure which (if any) browsers need the
tags.
Update:
More information in my second response:
Why doesn't IE7 copy
blocks to the clipboard correctly?