| 2:12 am on Feb 8, 2012 (gmt 0)|
You're going to need to add the language-specific parts yourself, but from the RegEx side:
You have to capture the entire text block in one go, so you can change
^blahblah blahblah blahblah$
blahblah blahblah blahblah
instead of treating each word as a separate unit.
If a single text block contains multiple paragraphs-- as your reference to <br /> implies-- then you've actually done the work already. Don't just insert a break: insert a break and a group of spaces at the same time.
I assume there's some compelling reason why you can't use
Paragraphs would make the whole problem go away, because you could then throw in a line or two of CSS to indent them all.
| 6:18 am on Feb 8, 2012 (gmt 0)|
Actually Lucy, you gave me a real eye opener. I see that you can actually add the style class to the <p> tag such as:
$request =~ s/\r\n/<p class=\"indent\">/g; if the class is needed and also no matter how many times they hit the spacebar the space between tparagraphs will always be the same unlike using the <br /> tag in which case if they hit the spacebar 5 times there would be 5 spaces between paragraphs where even if there are 5 <p> tags the distance between paragraphs remains at only one space. The only thing is, how do you include the closing </p> tag?
It is not that important that paragraphs are indented even though the way you described makes it possible--I was only thinking about people who like to indent paragraphs.
As far as adding css to regex---is this a rabbit you pulled out of a hat or something that has been done before---cool trick.
Thanx---gonna' have to put some thought into the direction I take on this one.
| 9:58 am on Feb 8, 2012 (gmt 0)|
the closing paragraph tag isn't required for validation in HTML (4 or 5) but is required in XHTML.
if the </p> is missing it will be implied by the opening tag of the next block-level element.
therefore you only need it if you want to validate for XHTML or if there isn't a new block level element where you need one.
i prefer to use the </p> tag in all cases to avoid ambiguity and future maintenance headaches.
one possible solution is to use your intended pattern for finding the space between paragraphs and replace the \r\n with </p><p class=... and then add the opening and closing paragraph tags to the beginning and end of the entire text block.
| 10:03 am on Feb 8, 2012 (gmt 0)|
Weird but true: If you don't care about it validating, you don't need a closing </p> tag in html4. But if you have multiple <p> statements there will be multiple empty lines.
If you can put <br> in your output then you can put <p> or <p class = "long complicated list of conditions"> or <a href = "worldsbestsite.com"> or anything else you want ;)
Now, as already noted, I don't speak the language, but if you can identify spaces in the text area can't you identify line breaks? Trim away any leading or trailing ones. Then you have <p> at the beginning, </p>\r\n<p> replacing each set of (\r\n)+ along the way, and a final </p> at the end.
Does the replacement just run once, or can you make a "while" type of iteration? You want it structured as "do such-and-such until you run out of things to do it to".
| 3:19 pm on Feb 12, 2012 (gmt 0)|
This started out as a "quest" of sorts and learned some things also which is good but I'm now convinced that the way to go is replacing the <textarea> with something like FCK editor and let it take care of everything. The indent was not really as important as the newlines.