S
Sandman
I am splitting a text block into paragraphs, to be able to add images and stuff
like that to a specific paragraph in a content management system.
Well, right now I'm splittin on two or more newlines, so this text block
(indentation added for clarity):
Hello, my nickname is Sandman and I am coding
some Perl
Call me
Would be split into two parts, with "Call me" being the second one.
My problem now is that if I have a text block like below:
Hello, my nickname is Sandman and I am coding
some Perl. Here is an example:
<code>
print "Hello World!";
print "Foo";
</code>
Call me
The above would, given the rules I use now, yield four parts, as such:
---------------------------------------------
Hello, my nickname is Sandman and I am coding
some Perl. Here is an example:
---------------------------------------------
<code>
print "Hello World!";
---------------------------------------------
print "Foo";
</code>
---------------------------------------------
Call me
---------------------------------------------
But I would want it to end up in three parts, as such:
---------------------------------------------
Hello, my nickname is Sandman and I am coding
some Perl. Here is an example:
---------------------------------------------
<code>
print "Hello World!";
print "Foo";
</code>
---------------------------------------------
Call me
---------------------------------------------
So, basically, what I want to do is to split the text block up with the
delimiter "\n{2,}" but not when it is inside an *unclosed* html tag. Some
examples:
<div class='quote'>
Hello, my nickname is Sandman and I am coding
some Perl. Here is an example:
<code>
print "Hello World!";
print "Foo";
</code>
Call me
</div>
Ends up in:
---------------------------------------------
<div class='quote'>
Hello, my nickname is Sandman and I am coding
some Perl. Here is an example:
<code>
print "Hello World!";
print "Foo";
</code>
Call me
</div>
---------------------------------------------
And
<div class='quote'>
Hello, my nickname is Sandman and I am coding
some Perl. Here is an example:
<code>
print "Hello World!";
print "Foo";
</code>
</div>
Call me
Ends up in:
---------------------------------------------
<div class='quote'>
Hello, my nickname is Sandman and I am coding
some Perl. Here is an example:
<code>
print "Hello World!";
print "Foo";
</code>
</div>
---------------------------------------------
Call me
---------------------------------------------
Hopefully you get the idea.
Any ideas on how to solve it?
like that to a specific paragraph in a content management system.
Well, right now I'm splittin on two or more newlines, so this text block
(indentation added for clarity):
Hello, my nickname is Sandman and I am coding
some Perl
Call me
Would be split into two parts, with "Call me" being the second one.
My problem now is that if I have a text block like below:
Hello, my nickname is Sandman and I am coding
some Perl. Here is an example:
<code>
print "Hello World!";
print "Foo";
</code>
Call me
The above would, given the rules I use now, yield four parts, as such:
---------------------------------------------
Hello, my nickname is Sandman and I am coding
some Perl. Here is an example:
---------------------------------------------
<code>
print "Hello World!";
---------------------------------------------
print "Foo";
</code>
---------------------------------------------
Call me
---------------------------------------------
But I would want it to end up in three parts, as such:
---------------------------------------------
Hello, my nickname is Sandman and I am coding
some Perl. Here is an example:
---------------------------------------------
<code>
print "Hello World!";
print "Foo";
</code>
---------------------------------------------
Call me
---------------------------------------------
So, basically, what I want to do is to split the text block up with the
delimiter "\n{2,}" but not when it is inside an *unclosed* html tag. Some
examples:
<div class='quote'>
Hello, my nickname is Sandman and I am coding
some Perl. Here is an example:
<code>
print "Hello World!";
print "Foo";
</code>
Call me
</div>
Ends up in:
---------------------------------------------
<div class='quote'>
Hello, my nickname is Sandman and I am coding
some Perl. Here is an example:
<code>
print "Hello World!";
print "Foo";
</code>
Call me
</div>
---------------------------------------------
And
<div class='quote'>
Hello, my nickname is Sandman and I am coding
some Perl. Here is an example:
<code>
print "Hello World!";
print "Foo";
</code>
</div>
Call me
Ends up in:
---------------------------------------------
<div class='quote'>
Hello, my nickname is Sandman and I am coding
some Perl. Here is an example:
<code>
print "Hello World!";
print "Foo";
</code>
</div>
---------------------------------------------
Call me
---------------------------------------------
Hopefully you get the idea.
Any ideas on how to solve it?