bhollis / maruku

A pure-Ruby Markdown-superset interpreter (Official Repo).
MIT License
502 stars 80 forks source link

Link containing Images with Markdown Extra CSS class not working #89

Closed gpoul closed 11 years ago

gpoul commented 11 years ago

While

[![Alt text](/Understanding-Big-Data-Cover-201x300.jpg){.alignright}](/big-data)

generates

<a href='/big-data'><img alt='Alt text' class='alignright' src='/Understanding-Big-Data-Cover-201x300.jpg' /></a>

the following causes a parsing error:

[![Alt text](/Understanding-Big-Data-Cover-201x300.jpg){.alignright}](http://testsite.com/big-data)
distler commented 11 years ago

I don't get a parsing error (though, admittedly, your input doesn't quite produce the desired output).

Adding a space after the IAL does produce the desired output, however.

[![Alt text](/Understanding-Big-Data-Cover-201x300.jpg){.alignright} ](http://testsite.com/big-data)

produces

<p><a href='http://testsite.com/big-data'><img alt='Alt text' class='alignright' src='/Understanding-Big-Data-Cover-201x300.jpg' /></a></p>

in 0.6.1 and

<p><a href="http://testsite.com/big-data"><img class="alignright" src="/Understanding-Big-Data-Cover-201x300.jpg" alt="Alt text" /></a></p>

on trunk.

gpoul commented 11 years ago

I confirmed the workaround you're suggesting with adding a blank. Without that blank Maruku-0.6.1 for me returns the following error:

 ___________________________________________________________________________
| Maruku tells you:
+---------------------------------------------------------------------------
| String finished while reading (break on ["}", "=", " ", "\t"]) already read: "//testsite.com/big-data)"
| ---------------------------------------------------------------------------
| ing-Big-Data-Cover-201x300.jpg){.alignright}](http://testsite.com/big-data)EOF
| ---------------------------------------------------------------------------|
|                                                                            +--- Byte 99
| Shown bytes [24 to 75] of 99:
| >[![Alt text](/Understanding-Big-Data-Cover-201x300.jpg){.alignright}](http://testsite.com/big-data)
| 
| At line 2
|       text     |[![Alt text](/Understanding-Big-Data-Cover-201x300.jpg){.alignright}](http://testsite.com/big-data)|
+---------------------------------------------------------------------------
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/errors_management.rb:49:in `maruku_error'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/input/parse_span_better.rb:402:in `read_simple'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/input/parse_span_better.rb:359:in `read_quoted_or_unquoted'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/attributes.rb:173:in `read_attribute_list'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/input/parse_span_better.rb:304:in `extension_meta'
\___________________________________________________________________________

 ___________________________________________________________________________
| Maruku tells you:
+---------------------------------------------------------------------------
| I boldly continue
| ---------------------------------------------------------------------------
| ing-Big-Data-Cover-201x300.jpg){.alignright}](http://testsite.com/big-data)EOF
| ---------------------------------------------------------------------------|
|                                                                            +--- Byte 99
| Shown bytes [24 to 75] of 99:
| >[![Alt text](/Understanding-Big-Data-Cover-201x300.jpg){.alignright}](http://testsite.com/big-data)
| 
| At line 2
|       text     |[![Alt text](/Understanding-Big-Data-Cover-201x300.jpg){.alignright}](http://testsite.com/big-data)|
+---------------------------------------------------------------------------
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/errors_management.rb:56:in `maruku_recover'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/input/parse_span_better.rb:403:in `read_simple'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/input/parse_span_better.rb:359:in `read_quoted_or_unquoted'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/attributes.rb:173:in `read_attribute_list'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/input/parse_span_better.rb:304:in `extension_meta'
\___________________________________________________________________________

 ___________________________________________________________________________
| Maruku tells you:
+---------------------------------------------------------------------------
| Attribute list terminated by EOF:
|  [[:ref, "//testsite.com/big-data)"]]
| ---------------------------------------------------------------------------
| ing-Big-Data-Cover-201x300.jpg){.alignright}](http://testsite.com/big-data)EOF
| ---------------------------------------------------------------------------|
|                                                                            +--- Byte 99
| Shown bytes [24 to 75] of 99:
| >[![Alt text](/Understanding-Big-Data-Cover-201x300.jpg){.alignright}](http://testsite.com/big-data)
| 
| At line 2
|       text     |[![Alt text](/Understanding-Big-Data-Cover-201x300.jpg){.alignright}](http://testsite.com/big-data)|
| 
| 
| Elements read in span: 
|  -md_im_image(["Alt text"], "/Understanding-Big-Data-Cover-201x300.jpg", nil)
+---------------------------------------------------------------------------
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/errors_management.rb:49:in `maruku_error'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/attributes.rb:148:in `read_attribute_list'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/input/parse_span_better.rb:304:in `extension_meta'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/input/parse_span_better.rb:283:in `interpret_extension'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/input/parse_span_better.rb:214:in `read_span'
\___________________________________________________________________________
I try to continue and return partial attribute list:
[[:ref, "//testsite.com/big-data)"]]
 ___________________________________________________________________________
| Maruku tells you:
+---------------------------------------------------------------------------
| Unclosed span (waiting for ["]"] ornil)
| ---------------------------------------------------------------------------
| ing-Big-Data-Cover-201x300.jpg){.alignright}](http://testsite.com/big-data)EOF
| ----------------------------------------------------------------------------|
|                                                                             +--- Byte 100
| Shown bytes [24 to 75] of 99:
| >[![Alt text](/Understanding-Big-Data-Cover-201x300.jpg){.alignright}](http://testsite.com/big-data)
| 
| At line 2
|       text     |[![Alt text](/Understanding-Big-Data-Cover-201x300.jpg){.alignright}](http://testsite.com/big-data)|
| 
| 
| Elements read in span: 
|  -md_im_image(["Alt text"], "/Understanding-Big-Data-Cover-201x300.jpg", nil)
|  -md_el(:ald,[],{:ald=>[[:ref, "//testsite.com/big-data)"]],:ald_id=>".alignright}](http"},[])
+---------------------------------------------------------------------------
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/errors_management.rb:49:in `maruku_error'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/input/parse_span_better.rb:222:in `read_span'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/input/parse_span_better.rb:544:in `read_link'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/input/parse_span_better.rb:146:in `read_span'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/input/parse_span_better.rb:46:in `parse_span_better'
\___________________________________________________________________________

 ___________________________________________________________________________
| Maruku tells you:
+---------------------------------------------------------------------------
| Could not find ref_id = "md_im_imagealt_text_understandingbigdatacover201x300jpg_nil_md_elaldaldref_testsitecombigdataald_idalignrighthttp" for md_link([
|   md_im_image(["Alt text"], "/Understanding-Big-Data-Cover-201x300.jpg", nil),
|   md_el(:ald,[],{:ald=>[[:ref, "//testsite.com/big-data)"]],:ald_id=>".alignright}](http"},[])
| ],"md_im_imagealt_text_understandingbigdatacover201x300jpg_nil_md_elaldaldref_testsitecombigdataald_idalignrighthttp")
| Available refs are []
+---------------------------------------------------------------------------
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/errors_management.rb:49:in `maruku_error'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/output/to_html.rb:716:in `to_html_link'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/output/to_html.rb:970:in `block in array_to_html'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/output/to_html.rb:961:in `each'
!/var/lib/gems/1.9.1/gems/maruku-0.6.1/lib/maruku/output/to_html.rb:961:in `array_to_html'
\___________________________________________________________________________
Not creating a link for ref_id = "md_im_imagealt_text_understandingbigdatacover201x300jpg_nil_md_elaldaldref_testsitecombigdataald_idalignright
bhollis commented 11 years ago

This was indeed a bug, which has now been tested for, and fixed, in master.

gpoul commented 11 years ago

Verified that this is now working for me. tnx!