Skip to content

Commit c390a9e

Browse files
authored
Merge pull request #700 from aidantwoods/fix/spaces-in-class-names-1.7.x
[1.7.x] Fix spaces in class names
2 parents 92e9c27 + 0f1e9da commit c390a9e

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ matrix:
1212
- php: 5.6
1313
- php: 7.0
1414
- php: 7.1
15+
- php: 7.2
16+
- php: 7.3
1517
- php: nightly
16-
- php: hhvm
17-
- php: hhvm-nightly
1818
fast_finish: true
1919
allow_failures:
2020
- php: nightly
21-
- php: hhvm-nightly
2221

2322
install:
2423
- composer install --prefer-dist --no-interaction --no-progress

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)