Closed rogerdawkins closed 6 years ago
I have used chop(limit=2, unit='p') but the returned string includes an additional leading paragraph tag. I checked the source data and that is clean.
Looking at the code in libs/hacksaw.php around line 88 the problem is caused by...
$return = "<p>"; foreach ($paragraphs as $key => $paragraph) { $return .= "<p>" . $paragraph; if ($key < $paragraphsCount) { $return .= "</p>"; } } $return .= $append . "</p>";
The $return variable is set to a paragraph tag but then inside the foreach loop each paragraph has a paragraph tag added as well resulting in two p tags at the start. Changing the first line to
$return = "";
would fix it.
@rogerdawkins good catch! Could you PR that to the 3.x.dev branch?
3.x.dev
Thanks @rogerdawkins!!!
I have used chop(limit=2, unit='p') but the returned string includes an additional leading paragraph tag. I checked the source data and that is clean.
Looking at the code in libs/hacksaw.php around line 88 the problem is caused by...
The $return variable is set to a paragraph tag but then inside the foreach loop each paragraph has a paragraph tag added as well resulting in two p tags at the start. Changing the first line to
would fix it.