From bc003952fcbed63be7489e19e4a2710ae978866e Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Sun, 17 Mar 2019 16:49:45 +0000 Subject: [PATCH] [1.7.x] Fix spaces in class names --- Parsedown.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Parsedown.php b/Parsedown.php index 87d612ab8..c5f01a3eb 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -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,