diff --git a/src/Components/Blocks/FencedCode.php b/src/Components/Blocks/FencedCode.php index 87d3bb4..a93dd1b 100644 --- a/src/Components/Blocks/FencedCode.php +++ b/src/Components/Blocks/FencedCode.php @@ -118,7 +118,23 @@ final class FencedCode implements ContinuableBlock */ public function stateRenderable() { - $infostring = $this->infostring(); + /** + * 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). + */ + $infostring = \substr( + $this->infostring(), + 0, + \strcspn($this->infostring(), " \t\n\f\r") + ); return new Element('pre', [], [new Element( 'code', diff --git a/tests/data/fenced_code_block.html b/tests/data/fenced_code_block.html index fd91256..2060e44 100644 --- a/tests/data/fenced_code_block.html +++ b/tests/data/fenced_code_block.html @@ -22,4 +22,7 @@ still a fenced code block bar + +
<?php
+echo "Hello World";
 
\ No newline at end of file diff --git a/tests/data/fenced_code_block.md b/tests/data/fenced_code_block.md index 3e4155a..81ca2ba 100644 --- a/tests/data/fenced_code_block.md +++ b/tests/data/fenced_code_block.md @@ -35,4 +35,9 @@ foo bar +``` + +```php some-class +