Skip to content

Commit 73206b0

Browse files
committed
fix(image-parser): fix ref style imgs after inline style imgs not parsing correctly
When reference style and inline style are mixed together, in the same line, it produces weird parsing bugs. This commit fixes this Closes #261
1 parent d91586b commit 73206b0

11 files changed

Lines changed: 71 additions & 7 deletions

dist/showdown.js

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/subParsers/images.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ showdown.subParser('images', function (text, options, globals) {
77
text = globals.converter._dispatch('images.before', text, options, globals);
88

99
var inlineRegExp = /!\[(.*?)]\s?\([ \t]*()<?(\S+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(['"])(.*?)\6[ \t]*)?\)/g,
10-
referenceRegExp = /!\[(.*?)][ ]?(?:\n[ ]*)?\[(.*?)]()()()()()/g;
10+
referenceRegExp = /!\[([^\]]*?)] ?(?:\n *)?\[(.*?)]()()()()()/g;
1111

1212
function writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title) {
1313

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<p><img src="https://raw.githubusercontent.com/showdownjs/logo/master/dist/logo.readme.png" alt="sd-inline" /> <a href="https://www.google.pt/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png">sd-ref</a></p>
2+
3+
<p>foo</p>
4+
5+
<p><a href="https://raw.githubusercontent.com/showdownjs/logo/master/dist/logo.readme.png">sd-inline</a> <img src="https://www.google.pt/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" alt="sd-ref" /></p>
6+
7+
<p>foo</p>
8+
9+
<p><img src="https://www.google.pt/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" alt="sd-ref" /> <a href="https://raw.githubusercontent.com/showdownjs/logo/master/dist/logo.readme.png">sd-inline</a></p>
10+
11+
<p>foo</p>
12+
13+
<p><a href="https://www.google.pt/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png">sd-ref</a> <img src="https://raw.githubusercontent.com/showdownjs/logo/master/dist/logo.readme.png" alt="sd-inline" /></p>
14+
15+
<p>foo</p>
16+
17+
<p><a href="http://www.google.com/"><img src="https://www.google.pt/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" alt="sd-ref" /></a></p>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
![sd-inline](https://raw.githubusercontent.com/showdownjs/logo/master/dist/logo.readme.png) [sd-ref][sd-logo]
2+
3+
foo
4+
5+
[sd-inline](https://raw.githubusercontent.com/showdownjs/logo/master/dist/logo.readme.png) ![sd-ref][sd-logo]
6+
7+
foo
8+
9+
![sd-ref][sd-logo] [sd-inline](https://raw.githubusercontent.com/showdownjs/logo/master/dist/logo.readme.png)
10+
11+
foo
12+
13+
[sd-ref][sd-logo] ![sd-inline](https://raw.githubusercontent.com/showdownjs/logo/master/dist/logo.readme.png)
14+
15+
foo
16+
17+
[![sd-ref][sd-logo]](http://www.google.com/)
18+
19+
[sd-logo]: https://www.google.pt/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<p><img src="https://raw.githubusercontent.com/showdownjs/logo/master/dist/logo.readme.png" alt="sd-inline" /> <img src="https://www.google.pt/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" alt="sd-ref" /></p>
2+
3+
<p>foo</p>
4+
5+
<p><img src="https://www.google.pt/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" alt="sd-ref" /> <img src="https://raw.githubusercontent.com/showdownjs/logo/master/dist/logo.readme.png" alt="sd-inline" /></p>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
![sd-inline](https://raw.githubusercontent.com/showdownjs/logo/master/dist/logo.readme.png) ![sd-ref][sd-logo]
2+
3+
foo
4+
5+
![sd-ref][sd-logo] ![sd-inline](https://raw.githubusercontent.com/showdownjs/logo/master/dist/logo.readme.png)
6+
7+
[sd-logo]: https://www.google.pt/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<p><a href="https://raw.githubusercontent.com/showdownjs/logo/master/dist/logo.readme.png">sd-inline</a> <a href="https://www.google.pt/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png">sd-ref</a></p>
2+
3+
<p>foo</p>
4+
5+
<p><a href="https://www.google.pt/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png">sd-ref</a> <a href="https://raw.githubusercontent.com/showdownjs/logo/master/dist/logo.readme.png">sd-inline</a></p>

0 commit comments

Comments
 (0)