Skip to content

Commit

Permalink
Fixed parsing of brackets within inline image titles.
Browse files Browse the repository at this point in the history
  • Loading branch information
geekman committed Jan 5, 2014
1 parent b6ed501 commit db12a32
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion markdown/inlinepatterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def build_inlinepatterns(md_instance, **kwargs):
r'''\(\s*(<.*?>|((?:(?:\(.*?\))|[^\(\)]))*?)\s*((['"])(.*?)\12\s*)?\)'''
# [text](url) or [text](<url>) or [text](url "title")

IMAGE_LINK_RE = r'\!' + BRK + r'\s*\((<.*?>|([^\)]*))\)'
IMAGE_LINK_RE = r'\!' + BRK + r'\s*\((<.*?>|([^")]+"[^"]*"|[^\)]*))\)'
# ![alttxt](http://x.com/) or ![alttxt](<http://x.com/>)
REFERENCE_RE = NOIMG + BRK+ r'\s?\[([^\]]*)\]' # [Google][3]
SHORT_REF_RE = NOIMG + r'\[([^\]]+)\]' # [Google]
Expand Down
9 changes: 9 additions & 0 deletions tests/misc/brackets-in-img-title.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<p><img alt="alt" src="local-img.jpg" />
<img alt="alt" src="local-img.jpg" title="" />
<img alt="alt" src="local-img.jpg" title="normal title" /></p>
<p><img alt="alt" src="local-img.jpg" title="(just title in brackets)" />
<img alt="alt" src="local-img.jpg" title="title with brackets (I think)" /></p>
<p><img alt="alt" src="local-img.jpg" title="(" />
<img alt="alt" src="local-img.jpg" title="(open only" />
<img alt="alt" src="local-img.jpg" title=")" />
<img alt="alt" src="local-img.jpg" title="close only)" /></p>
12 changes: 12 additions & 0 deletions tests/misc/brackets-in-img-title.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
![alt](local-img.jpg)
![alt](local-img.jpg "")
![alt](local-img.jpg "normal title")

![alt](local-img.jpg "(just title in brackets)")
![alt](local-img.jpg "title with brackets (I think)")

![alt](local-img.jpg "(")
![alt](local-img.jpg "(open only")
![alt](local-img.jpg ")")
![alt](local-img.jpg "close only)")

0 comments on commit db12a32

Please sign in to comment.