Skip to content

Commit

Permalink
Port fix for #699 into new
Browse files Browse the repository at this point in the history
codebase
  • Loading branch information
aidantwoods committed Apr 6, 2019
1 parent c744fb9 commit ae0fa5f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Components/Blocks/FencedCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,23 @@ public function code()
*/
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',
Expand Down
3 changes: 3 additions & 0 deletions tests/data/fenced_code_block.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@


bar
</code></pre>
<pre><code class="language-php">&lt;?php
echo &quot;Hello World&quot;;
</code></pre>
5 changes: 5 additions & 0 deletions tests/data/fenced_code_block.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@ foo
bar
```

```php some-class
<?php
echo "Hello World";
```

0 comments on commit ae0fa5f

Please sign in to comment.