Skip to content

Commit

Permalink
Retain newlines for code blocks when the code tag has attributes
Browse files Browse the repository at this point in the history
Fixes #234.
  • Loading branch information
coffee2code committed Apr 10, 2023
1 parent 85a4a8f commit d4d8751
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ function fix_newlines( $text ) {

// Replace newline characters within 'code' and 'pre' tags with replacement string.
$text = preg_replace_callback(
"/(?<=<pre><code>)(.+)(?=<\/code><\/pre>)/s",
"/(<pre><code[^>]*>)(.+)(?=<\/code><\/pre>)/sU",
function ( $matches ) use ( $replacement_string ) {
return preg_replace( '/[\n\r]/', $replacement_string, $matches[1] );
return preg_replace( '/[\n\r]/', $replacement_string, $matches[1] . $matches[2] );
},
$text
);
Expand Down

0 comments on commit d4d8751

Please sign in to comment.