Skip to content

Commit

Permalink
[1.7.x] Fix spaces in class names
Browse files Browse the repository at this point in the history
  • Loading branch information
aidantwoods committed Mar 17, 2019
1 parent 92e9c27 commit bc00395
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Parsedown.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,21 @@ protected function blockFencedCode($Line)

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

$class = 'language-'.$language;

$Element['attributes'] = array(
'class' => $class,
Expand Down

0 comments on commit bc00395

Please sign in to comment.