Comments (5)
I "cleaned" the new code up some. First, inserting "\r\n" causes some lines to
be
indented by one space. Instead, insert only "\r". Below is the new updated
code. Note
that the insertAfter method is no longer needed.
//GDQV - Added the following method to make copy/paste work correctly.
// This "restores" the line breaks that IE stripped out when using
// .innerHTML property.
/** Replace <br>s with \r directly in DOM
*
* @param elem as DOM element with <br>s
*/
function replaceBrsWithCrLf(elem) {
var brs = elem.getElementsByTagName("br");
// Insert all the \r first. Work bottom to top, because I believe the
// collection is "live".
// Inserting \r\n causes a leading space to appear on some lines.
for (var i = brs.length; i-- > 0; ) {
var crlf = document.createTextNode("\r");
brs[i].parentNode.replaceChild(crlf, brs[i]);
}
}
Original comment by [email protected]
on 27 Sep 2007 at 3:26
from code-prettify.
I can repeat the bug. I'd rather not use \r for newlines since that's counter
to the
spec, and CR isn't used as eol in any OS except commodores and old versions of
MacOS.
Original comment by [email protected]
on 23 Oct 2007 at 3:12
- Changed state: Accepted
from code-prettify.
I played around a bit.
Thanks for suggesting the \r trick. I'm leery of how it'll affect other
browsers,
and this rewriting step isn't cheap so I'd rather not do it for all the
browsers that
don't have this problem.
I've managed to avoid browser detection thus-far, but I think using it here
yields
simpler code.
I fixed it by replacing <br> with \r\n but only on IE 6.
Original comment by [email protected]
on 23 Oct 2007 at 4:49
from code-prettify.
I see you say you replaced <br> with \r\n. Notice my post on Sept 26, 2007;
using
\r\n causes some lines to be indented by a single space. I did not track down
the
reason/conditions for those lines, but changing to only \r fixed that problem.
Original comment by [email protected]
on 24 Oct 2007 at 4:42
from code-prettify.
@r62. use '\r' instead of '\r\n' on IE6 to separate lines.
Original comment by [email protected]
on 14 Jan 2009 at 8:13
- Changed state: Fixed
from code-prettify.
Related Issues (20)
- Add support for Chapel? HOT 2
- [Feature Request] Add diff / patch highlighting support for StackExchange websites. HOT 1
- Add support for Idris
- No GitHub wiki
- Add support for Perl6 HOT 1
- How to use `Google Code Prettifier` to VBA macro in Microsoft Excel ?
- Add support for AppleScript HOT 1
- White space indentation added on Firefox when using linenums class
- Performance problem with "Hit Test" in Chrome HOT 1
- Wrong highlighting on stackoverflow.com vba if default is used HOT 1
- Extra white-space appears on the first line HOT 1
- XSS risks?
- Request: terraform / hcl language support HOT 2
- Golang run-on string when backticks appear to be escaped
- Makefile: is it really supported?
- Request support of ChoiceScript language
- Added 'record' among Java keywords
- How auto justify codes?
- Request support for DigitalMicrograph Scripting language (DM-script)
- Add support to MiniZinc
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from code-prettify.