Skip to content

Commit

Permalink
Preserve line numbering in older php versions
Browse files Browse the repository at this point in the history
Signed by Shawn Bulen, [email protected]
  • Loading branch information
sbulen committed Oct 8, 2024
1 parent c94f8e7 commit d68decb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/BBCodeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2087,6 +2087,10 @@ public static function highlightPhpCode(string $code): string
// PHP 8.3 changed the returned HTML.
$buffer = preg_replace('/^(<pre>)?<code[^>]*>|<\/code>(<\/pre>)?$/', '', $buffer);

// Remove line breaks inserted before & after the actual code in php < 8.3
$buffer = preg_replace('/^(<span\s[^>]*>)<br \/>/', '$1', $buffer);
$buffer = preg_replace('/<br \/>(<span\s[^>]*>)<br \/>$/', '$1', $buffer);

return strtr($buffer, ['\'' => '&#039;']);
}

Expand Down

0 comments on commit d68decb

Please sign in to comment.