Skip to content

Commit

Permalink
first character in a reference name should not be [
Browse files Browse the repository at this point in the history
  • Loading branch information
cebe committed Mar 26, 2018
1 parent dcbe549 commit bf05759
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@ Version 1.2.1 work in progress
------------------------------

- Improved handling of inline HTML with URL and email tags.
- Improved handling of custom syntax with `[[`, references should not use `[` as the first character in the reference name.

Version 1.2.0 on 14. Mar. 2018
------------------------------
Expand Down
2 changes: 1 addition & 1 deletion MarkdownExtra.php
Expand Up @@ -69,7 +69,7 @@ class MarkdownExtra extends Markdown

protected function identifyReference($line)
{
return ($line[0] === ' ' || $line[0] === '[') && preg_match('/^ {0,3}\[(.+?)\]:\s*([^\s]+?)(?:\s+[\'"](.+?)[\'"])?\s*('.$this->_specialAttributesRegex.')?\s*$/', $line);
return ($line[0] === ' ' || $line[0] === '[') && preg_match('/^ {0,3}\[[^\[](.*?)\]:\s*([^\s]+?)(?:\s+[\'"](.+?)[\'"])?\s*('.$this->_specialAttributesRegex.')?\s*$/', $line);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion inline/LinkTrait.php
Expand Up @@ -254,7 +254,7 @@ protected function renderImage($block)

protected function identifyReference($line)
{
return isset($line[0]) && ($line[0] === ' ' || $line[0] === '[') && preg_match('/^ {0,3}\[(.+?)\]:\s*([^\s]+?)(?:\s+[\'"](.+?)[\'"])?\s*$/', $line);
return isset($line[0]) && ($line[0] === ' ' || $line[0] === '[') && preg_match('/^ {0,3}\[[^\[](.*?)\]:\s*([^\s]+?)(?:\s+[\'"](.+?)[\'"])?\s*$/', $line);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions tests/markdown-data/list_items_with_undefined_ref.html
Expand Up @@ -8,3 +8,7 @@
it to use by setting its <code>db</code> property.</p>
</li>
</ul>
<ul>
<li>[[yii\caching\Cache::get()|get()]]: 指定されたキーを用いてキャッシュからデータを取得します。データが見つからないか、もしくは有効期限が切れたり無効になったりしている場合は false を返します。</li>
<li>[[yii\caching\Cache::set()|set()]]: キーによって識別されるデータをキャッシュに格納します。</li>
</ul>
4 changes: 4 additions & 0 deletions tests/markdown-data/list_items_with_undefined_ref.md
Expand Up @@ -5,3 +5,7 @@
* [[\yii\caching\DbCache]]: uses a database table to store cached data. By default, it will create and use a
[SQLite3](http://sqlite.org/) database under the runtime directory. You can explicitly specify a database for
it to use by setting its `db` property.


* [[yii\caching\Cache::get()|get()]]: 指定されたキーを用いてキャッシュからデータを取得します。データが見つからないか、もしくは有効期限が切れたり無効になったりしている場合は false を返します。
* [[yii\caching\Cache::set()|set()]]: キーによって識別されるデータをキャッシュに格納します。

0 comments on commit bf05759

Please sign in to comment.