Skip to content

Commit

Permalink
Properly support fenced code block infostring
Browse files Browse the repository at this point in the history
  • Loading branch information
aidantwoods committed Aug 20, 2017
1 parent 728952b commit 4404201
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Parsedown.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ protected function blockCommentContinue($Line, array $Block)

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',
Expand Down Expand Up @@ -515,10 +515,10 @@ protected function blockList($Line)
),
);

if($name === 'ol')
if($name === 'ol')
{
$listStart = stristr($matches[0], '.', true);

if($listStart !== '1')
{
$Block['element']['attributes'] = array('start' => $listStart);
Expand Down
3 changes: 2 additions & 1 deletion test/data/fenced_code_block.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
4 changes: 4 additions & 0 deletions test/data/fenced_code_block.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ tilde

```php
echo 'language identifier';
```

```c#
echo 'language identifier with non words';
```

0 comments on commit 4404201

Please sign in to comment.