Add your markup first. Then use something like the following to add your "linebreaks" (which I gather are newlines from reading your problem description):
That will allow you to treat your markup tags as a single character when trying to decide where to put your newlines. You may need the /s modifier to deal with existing newlines.s!((?:<span>|</span>|.){80})!$1\n!g;
Edit: Fixed thinko. I meant /s rather than /m of course.
-sauoq "My two cents aren't worth a dime.";
In reply to Re: highlight and line breaks
by sauoq
in thread highlight and line breaks
by glwtta
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |