Skip to content

Commit 4e7a6b7

Browse files
authored
Merge pull request #138 from Automattic/fix/classname-through-block
Add parse classname attribute to syntaxhighlighter block
2 parents e53ba0c + 53786a3 commit 4e7a6b7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

syntaxhighlighter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ public function enable_brushes_via_raw_html_parsing( $content ) {
500500
*/
501501
public function render_block( $attributes, $content ) {
502502
$remaps = array(
503+
'className' => 'classname',
503504
'lineNumbers' => 'gutter',
504505
'firstLineNumber' => 'firstline',
505506
'highlightLines' => 'highlight',
@@ -1243,7 +1244,7 @@ function shortcode_callback( $atts, $code = '', $tag = false ) {
12431244

12441245
// Sanitize the "classname" parameter
12451246
if ( 'class-name' == $key )
1246-
$value = trim( preg_replace( '/[^a-zA-Z0-9 _-]/i', '', $value ) );
1247+
$value = "'" . trim( preg_replace( '/[^a-zA-Z0-9 _-]/i', '', $value ) ) . "'";
12471248

12481249
// Special sanitization for "pad-line-numbers"
12491250
if ( 'pad-line-numbers' == $key ) {

0 commit comments

Comments
 (0)