Giter VIP home page Giter VIP logo

Comments (5)

GoogleCodeExporter avatar GoogleCodeExporter commented on May 25, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 25, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 25, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 25, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 25, 2024
@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.