Skip to content

Commit bc00395

Browse files
committed
[1.7.x] Fix spaces in class names
1 parent 92e9c27 commit bc00395

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Parsedown.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,21 @@ protected function blockFencedCode($Line)
429429

430430
if (isset($matches[1]))
431431
{
432-
$class = 'language-'.$matches[1];
432+
/**
433+
* https://www.w3.org/TR/2011/WD-html5-20110525/elements.html#classes
434+
* Every HTML element may have a class attribute specified.
435+
* The attribute, if specified, must have a value that is a set
436+
* of space-separated tokens representing the various classes
437+
* that the element belongs to.
438+
* [...]
439+
* The space characters, for the purposes of this specification,
440+
* are U+0020 SPACE, U+0009 CHARACTER TABULATION (tab),
441+
* U+000A LINE FEED (LF), U+000C FORM FEED (FF), and
442+
* U+000D CARRIAGE RETURN (CR).
443+
*/
444+
$language = substr($matches[1], 0, strcspn($matches[1], " \t\n\f\r"));
445+
446+
$class = 'language-'.$language;
433447

434448
$Element['attributes'] = array(
435449
'class' => $class,

0 commit comments

Comments
 (0)