I'm having a hard time with what I'm sure is a simple thing. I am making html pages out of a large number of text files.
I have code that adds markup for everything I want except paragraph formatting.
All of the text I am concerned with is in an array (@ThisFileArray), and it's just a bunch of text, with paragraphs separated by an extra newline. Kind of like this:
Text blah blah, make my point here. More text and even more continuing on along the way.
New paragraph starts here, there were 2 newlines just before I started this paragraph, so I should somehow be able
to match on that, but I can't figure out how to search for that through my array.
If I could do that, then I would search something like:
s/\n\n/</p>\n\n\<p>/m so that I would add a close paragraph tag at the end of the previous paragraph,
and an open paragraph tag at the beginning of the next.
Of course, I want to add a
<p> tag at the beginning of the array, to insert it at the beginning
of the text, and then add one final
</p> tag at the end of the text, to make everything really nice.
The end result would be (ideally) something like this:
<p>Text blah blah, make my point here. More text and even more continuing on along the way.
</p>
<p>New paragraph starts here, there were 2 newlines just before I started this paragraph, so I should somehow be able
to match on that, but I can't figure out how to search for that through my array.
</p>
I have tried this:
while (<@ThisFileArray>) {
s/\n\n/</p>\n\n<p>/m
}
But clearly I am missing some key ingredient here, because it doesn't work. Can anyone provide some enlightenment to this frustrated newbie?
Thanks so much.
Mark