Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions syntaxhighlighter.php
Original file line number Diff line number Diff line change
Expand Up @@ -555,19 +555,18 @@ public function render_block( $attributes, $content ) {
}
}

$code = preg_replace( '#<pre [^>]+>([^<]+)?</pre>#', '$1', $content );
$code = preg_replace( '#<pre(?: [^>]*)?>([\s\S]*?)</pre>#', '$1', $content );

$language = null;
if ( isset( $attributes['language'] ) ) {
$language = $attributes['language'];
}
if ( isset( $this->brushes[ $language ] ) ) {
// Undo escaping done by WordPress
$code = htmlspecialchars_decode( $code );
}
// Undo escaping done by WordPress
$code = htmlspecialchars_decode( $code );
$code = preg_replace( '/^(\s*https?:)&#0?47;&#0?47;([^\s<>"]+\s*)$/m', '$1//$2', $code );

// Block content is always raw at this point, so treat it as such
// regardless of the post's stored code format.
$previous_codeformat = $this->codeformat;
$this->codeformat = 1;
$code = $this->shortcode_callback( $attributes, $code, 'code' );
$this->codeformat = $previous_codeformat;

return '<div class="wp-block-syntaxhighlighter-code ' . esc_attr( join( ' ', $classnames ) ) . '">' . $code . '</div>';
}
Expand Down