redcocker,
Thanks for the reply. As for #1 when you copy from visual studio all new lines are defined with CRLF or in other words, \r\n is the newline identifier. So unfortunitely Alex’s code puts two lines for each 1 newline you paste in. In your code though you can prevent that by checking for [\r]?\n which means \r is optional and it will replace both \r\n and \n with
Oops, the code that got posted from me removed the <br>
so the proper code is
var code = document.getElementById('shtb_box_code').value.replace(/</g,'<').replace(/[\r]?\n/g,'<br>');
Sorry for the confusion on that.
For #2 I’m still messing with that fix that I made because then word wrapping wasn’t working properly after I changed that. Basically what the problem is, I select the text hit ctrl-c to copy the text and when you paste it there is no \n or \r\n so all the text in the box is output as 1 big line.