+1  A: 
Sbm007
ok, but if i change that in file 1 (which is the one that isn't working) then i won't be getting the desired effect in either?
Neil Hickman
Well do the opposite in file 1 then, replace $copy = preg_replace('^(.*)\n(.*)^', '$1<br />$2', $js_r->copy); $copy = preg_replace('/[\r]+/', '$1<br />$2', $copy); with $copy = preg_replace('/[\r]+/', '$1<br />$2', $js_r->copy);I apologize for the lack of code formatting in comments.
Sbm007
it could work, but then as in another question i had that originally we came to the conclusion that the parsing of \n is required, otherwise it will break my javascript that i have. i'm out the office at the moment so when i get back i'll try it and let you know.
Neil Hickman
Yeah I found that quite odd in your code, you could just simply do a $code = str_replace("\n", "<br />", $js_r->copy); That's 2 lines in 1 and better performance. Not entirely sure why you decided to use regular expressions for this, as that is overkill.
Sbm007
as i imagined, that has now broken the first file as in the same problem i had with the original question
Neil Hickman
A: 

Ok,

So it seems it was the parsing of the line breaks in the file... However we have changed it from
as this is causing the issue of the markdown parsing incorrectly to double escaped

so it now reads

$copy = preg_replace("/\n/", "\\\\n", $js_r->copy);
$copy = preg_replace("/\r/", "\\\\r", $copy);

which works correctly and parses both files efficiently

Neil Hickman
Ok, glad it worked out well. By the way you may want to consider using str_replace instead of preg_replace as it is much faster (non regex).
Sbm007
i did take up your advise after i posted that ... i'm all for saving resources... thanks for pointing me in the right direction anyway!
Neil Hickman