I'm rolling my own journaling scripts. I want to avoid having to manually place the P tags and such around the proper sections of a post so as to maintain XHTML 1.0 Strict compliance. For instance, consider the following sentence:
This is a sample sentence.
Since there are two newline characters before this sentence, it should be in it's own paragraph. Further, consider that there is a list buried in the text such as follows:<ul>...<ul>
Now here is another paragraph.
There in only one newline character before this sentence and thus, this should not be considered a new paragraph and just a line break.
I'm looking for a regexp or at least a method of combining regular expressions to turn the above into this:
<p>This is a sample sentence.</p>
<p> there are two newline characters before this sentence, it should be in it's own paragraph. Further, consider that there is a list buried in the text such as follows:<p>
<ul>...</ul>
<p>Now here is another paragraph.<br />
There in only one newline character before this sentence and thus, this should not be considered a new paragraph and just a line break.</p>
How should something like this be accomplished? I've been attempting to generate a single regexp to handle this and have come close with b[\n\s]((<([duo]l).>)[.\n\w\s<>'/=":,()]*</\4>)[/b] but this doesn't quite hit the nail on the head. Any ideas or tips on accomplishing this goal?