Skip to content

Commit

Permalink
Litedown: fixed support for images without alt text
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Jul 23, 2015
1 parent 232396a commit 40e29fc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Plugins/Litedown/Parser.js
Expand Up @@ -731,7 +731,7 @@ function matchImages()
return;
}

var m, regexp = /!\[([^\x17\]]+)] ?\(([^\x17 ")]+)(?: "([^\x17"]*)")?\)/g;
var m, regexp = /!\[([^\x17\]]*)] ?\(([^\x17 ")]+)(?: "([^\x17"]*)")?\)/g;
while (m = regexp.exec(text))
{
var matchPos = m['index'],
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/Litedown/Parser.php
Expand Up @@ -740,7 +740,7 @@ protected function matchImages()
}

preg_match_all(
'/!\\[([^\\x17\\]]++)] ?\\(([^\\x17 ")]++)(?> "([^\\x17"]*+)")?\\)/',
'/!\\[([^\\x17\\]]*+)] ?\\(([^\\x17 ")]++)(?> "([^\\x17"]*+)")?\\)/',
$this->text,
$matches,
PREG_OFFSET_CAPTURE | PREG_SET_ORDER,
Expand Down
4 changes: 4 additions & 0 deletions tests/Plugins/Litedown/ParserTest.php
Expand Up @@ -850,6 +850,10 @@ function ($configurator)
'.. ![Alt text](http://example.org/img.png "Image (title)") ..',
'<r><p>.. <IMG alt="Alt text" src="http://example.org/img.png" title="Image (title)"><s>![</s>Alt text<e>](http://example.org/img.png "Image (title)")</e></IMG> ..</p></r>'
],
[
'.. ![](http://example.org/img.png) ..',
'<r><p>.. <IMG alt="" src="http://example.org/img.png"><s>![</s><e>](http://example.org/img.png)</e></IMG> ..</p></r>'
],
// Images in links
[
'.. [![Alt text](http://example.org/img.png)](http://example.org/) ..',
Expand Down

0 comments on commit 40e29fc

Please sign in to comment.