1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Properly support fenced code block infostring

Reference: http://spec.commonmark.org/0.28/#info-string
This commit is contained in:
Aidan Woods 2017-08-20 10:28:46 +01:00
parent 728952b90a
commit 4404201175
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
3 changed files with 9 additions and 4 deletions

View File

@ -396,7 +396,7 @@ class Parsedown
protected function blockFencedCode($Line)
{
if (preg_match('/^['.$Line['text'][0].']{3,}[ ]*([\w-]+)?[ ]*$/', $Line['text'], $matches))
if (preg_match('/^['.$Line['text'][0].']{3,}[ ]*([^`]+)?[ ]*$/', $Line['text'], $matches))
{
$Element = array(
'name' => 'code',
@ -515,10 +515,10 @@ class Parsedown
),
);
if($name === 'ol')
if($name === 'ol')
{
$listStart = stristr($matches[0], '.', true);
if($listStart !== '1')
{
$Block['element']['attributes'] = array('start' => $listStart);

View File

@ -3,4 +3,5 @@
$message = 'fenced code block';
echo $message;</code></pre>
<pre><code>tilde</code></pre>
<pre><code class="language-php">echo 'language identifier';</code></pre>
<pre><code class="language-php">echo 'language identifier';</code></pre>
<pre><code class="language-c#">echo 'language identifier with non words';</code></pre>

View File

@ -11,4 +11,8 @@ tilde
```php
echo 'language identifier';
```
```c#
echo 'language identifier with non words';
```