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 google-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 google-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 google-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 google-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 google-code-prettify.
Related Issues (20)
- Perl syntax highlighting does not recognize POD and highlights quotes in comments
- Bash "$#" treated as comment HOT 1
- Integration for Presentation
- Patch for /trunk/src/lang-css.js
- "><img src=x onerror=prompt(1);> HOT 2
- Feature request: AspectJ syntax highlighting.
- gzip disabled
- Patch for /trunk/js-modules/run_prettify.js
- Patch for /trunk/src/lang-vb.js
- Line numbers carry over in clipboard using IE 11.
- Patch for /trunk/src/awkirin.css
- Problem with backslash in VB
- FLOW_CONTROL_KEYWORDS should not contain `do`
- Syntax Highlighting for Rebol (and Red) programming languages
- Patch for /trunk/styles/sons-of-obsidian.css
- Syntax highlight for Robot Framework syntax
- Patch for /trunk/src/prettify.css HOT 1
- Inconsist TCL Syntax higlighter
- Patch for /trunk/src/lang-sql.js
- Patch for /trunk/styles/sons-of-obsidian.css
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 google-code-prettify.