Skip to content

Commit d4d8751

Browse files
committed
Retain newlines for code blocks when the code tag has attributes
Fixes #234.
1 parent 85a4a8f commit d4d8751

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/runner.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ function fix_newlines( $text ) {
154154

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

0 commit comments

Comments
 (0)