Assume an article generated my markdown which has 1-N paragraphs in it. My brain is a bit fried tonight, all I could come up with was
var chunks = s.split('</p>');
if ( chunks.length > 3)
{
s = chunks[1]+'</p>'+chunks[2]+'</p>'+chunks[3]+'</p>';
}
Is there a more sane way to collect the first three paragraphs into a string? The markdown processor guarantees the paragraphs should be legal HTML. But I'm sure there must be a more clever regex solution. Also this won't guarantee three paragraphs if there is something else like a but that's OK.