xer21
Forum Replies Created
-
Forum: Plugins
In reply to: [WP SyntaxHighlighter] [Plugin: WP SyntaxHighlighter] Copy/Paste (annoying)Thank you very much.
Forum: Plugins
In reply to: [WP SyntaxHighlighter] [Plugin: WP SyntaxHighlighter] Copy/Paste (annoying)redcocker,
I checked Alex’s site, and it appears someone provided a fix last month and he merged it with his code. However the build is not updated and I couldnt find the source. They said the fix was in the “shCore.js” file in function eachLine, the fix was to changereturn lines.join(‘\n’);
to
return lines.join(‘\r\n’);but I’m not sure if that will work or not I have not tested it.
Forum: Plugins
In reply to: [WP SyntaxHighlighter] [Plugin: WP SyntaxHighlighter] Copy/Paste (annoying)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 withOops, 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.