Skip to content

Commit

Permalink
Accept links endinng with special characters when enclosed in square …
Browse files Browse the repository at this point in the history
…brackets. [#16 state:resolved]
  • Loading branch information
jgarber committed Jul 21, 2008
1 parent dbad718 commit dc5512f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion ext/redcloth_scan/redcloth_inline.rl
Expand Up @@ -13,7 +13,8 @@

# links
link_says = ( C_noactions "."* " "* (mtext+ -- '":') ) >A %{ STORE(link_text); } ;
link = ( "["? '"' link_says '":' %A uri %{ STORE_URL(href); } :> "]"? ) >X ;
link = ( '"' link_says '":' %A uri %{ STORE_URL(href); } ) >X ;
bracketed_link = ( '["' link_says '":' %A uri %{ STORE(href); } :> "]" ) >X ;

# images
image_src = ( uri ) >A %{ STORE(src) } ;
Expand Down Expand Up @@ -84,6 +85,7 @@
image { INLINE(block, image); };

link { PARSE_LINK_ATTR(link_text); PASS(block, name, link); };
bracketed_link { PARSE_LINK_ATTR(link_text); PASS(block, name, link); };

code { PARSE_ATTR(text); PASS_CODE(block, text, code, opts); };
code_tag_start { CAT(block); fgoto code_tag; };
Expand Down
14 changes: 13 additions & 1 deletion test/links.yml
Expand Up @@ -199,4 +199,16 @@ html: '<p><a href="http://slashdot.org/">He said it is &#8220;very unlikely&#822
---
name: linked quoted phrase
in: '""Open the pod bay doors please, HAL."":http://www.youtube.com/watch?v=npN9l2Bd06s'
html: '<p><a href="http://www.youtube.com/watch?v=npN9l2Bd06s">&#8220;Open the pod bay doors please, <span class="caps">HAL</span>.&#8221;</a></p>'
html: '<p><a href="http://www.youtube.com/watch?v=npN9l2Bd06s">&#8220;Open the pod bay doors please, <span class="caps">HAL</span>.&#8221;</a></p>'
---
name: links containing underscores
in: 'This is a link to a "Wikipedia article about Barack":http://en.wikipedia.org/wiki/Barack_Obama'
html: '<p>This is a link to a <a href="http://en.wikipedia.org/wiki/Barack_Obama">Wikipedia article about Barack</a></p>'
---
name: links containing parentheses
in: 'This is a link to a ["Wikipedia article about Textile":http://en.wikipedia.org/wiki/Textile_(markup_language)]'
html: '<p>This is a link to a <a href="http://en.wikipedia.org/wiki/Textile_(markup_language)">Wikipedia article about Textile</a></p>'
---
name: links contained in parentheses
in: 'This is a regular link (but in parentheses: "Google":http://www.google.com)'
html: '<p>This is a regular link (but in parentheses: <a href="http://www.google.com">Google</a>)</p>'

0 comments on commit dc5512f

Please sign in to comment.