Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Convert double line breaks only?
I have a site where users will often be copying and pasting text into textareas in the Write panel. Thing is, when you copy text from this particular source, you end up with line breaks for the end of each line (where it “word wraps”). So, for now the best option I’ve found is to “Leave text untouched”. This effectively eliminates all those extra line breaks, but unless someone manually types <br> or <p> tags, there’s no way to get ANY line break, and I know no one is going to type HTML.
Wondering if there is a way to “convert double line breaks”. This way, the single line breaks you get when copying and pasting will be ignored, but if you manually make a double line break, that would get treated properly. Any help or ideas for another solution are much appreciated.
Last edited by aswihart (2009-12-03 21:18:48)
Offline
Re: Convert double line breaks only?
By not copy pasting content or by using a editor that handles word wrap correctly. I supose you are meaning an editor and not copy pasting copyrighted content.
More unelegant way is to use some sort of editor and conf it to not insert line breaks. Modifing classTextile.php to not insert br is also possible (like removing <br />
from doBr
function or by doubling newlines in p/br functions).
Because you want to get rid of <br />
you can also rah_replace it off from the resulting markup. It’s slow and better would be not to save the brs at all. But anyway.
<txp:rah_replace from="<br />" to="">
<txp:body />
</txp:rah_replace>
Offline
Re: Convert double line breaks only?
Yes, it would be ideal if I could get around having the line breaks to begin with, but sadly, this is the way it is going to be! And no this is not copyrighted content, I’m just using bits of reports on a website for teaching purposes. Check it out
Thank you for the insights and suggestions, it seems there a several ways to strip out <br> tags in addition to using “leave text untouched”. But am I wrong in thinking that with your solutions, users will still essentially be stuck without the ability to make a line break manually (by making a double line break)?
Last edited by aswihart (2009-12-03 22:18:37)
Offline
Re: Convert double line breaks only?
Depending on whether you have textile on, double ‘line breaks’ creates a paragraph (<p>
). A single ‘line break’ inserts a <br />
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Convert double line breaks only?
OK now I understand the reason for Els’ suggestions, and I did exactly what he said with deleting <br />
from the doBr function in classTextile.php, and it works perfectly. It was kind of iffy as to what deleting that would do, given <br />
occurs twice mingled in a jumble of expressions I could not hope to understand, but it worked like a charm.
I also tried using rah_replace and I think I will stick with that solution. It works just as well and is obviously more flexible. Thank you both very much!
Last edited by aswihart (2009-12-04 09:15:32)
Offline
#6 2009-12-04 10:29:23
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Convert double line breaks only?
aswihart wrote:
Els’ suggestions
Credits belong to Gocom, I had no part in this (and I’m not that clever) ;)
Offline
Pages: 1