bhollis / maruku

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

Empty code tags #108

Closed mcarpenter closed 10 years ago

mcarpenter commented 11 years ago

0.7 or current HEAD throws verbose warning when parsing empty code string. This is a definite improvement over 0.6 (which threw NoMethodError) and the resulting HTML is sane but perhaps still isn't quite as clean as it might be? (If this behavior is intentional or unaviodable then please close this issue straight away). Output (ruby 1.9.3):

irb(main):001:0> require 'maruku'
=> true
irb(main):002:0> x = Maruku.new('``')

 ___________________________________________________________________________
| Maruku tells you:
+---------------------------------------------------------------------------
| String finished while reading (break on []) already read: ""
| ---------------------------------------------------------------------------
| ``EOF
| --|-------------------------------------------------------------------------
|   +--- Byte 2
| Shown bytes [0 to 2] of 2:
| >``
| 
| At line 2
|       text     |``|
|
+---------------------------------------------------------------------------
!/d1/home/mcarpenter/maruku/lib/maruku/input/parse_span.rb:359:in `read_simple'
!/d1/home/mcarpenter/maruku/lib/maruku/input/parse_span.rb:450:in `read_inline_code'
!/d1/home/mcarpenter/maruku/lib/maruku/input/parse_span.rb:61:in `read_span'
!/d1/home/mcarpenter/maruku/lib/maruku/input/parse_span.rb:14:in `parse_span'
\___________________________________________________________________________

=> md_el(:document, md_par([]))
irb(main):003:0> x.to_html
=> "\n<p></p>\n"
irb(main):004:0> 
bhollis commented 11 years ago

Yeah, it's still less than optimal. Maruku's "parser" isn't very good and has trouble with the backtracking that's required to do this properly. I'll think about how to make this less of a mess.

Just out of curiosity, why do you have empty code ticks?

mcarpenter commented 11 years ago

I have a report generator that outputs markdown. I moved up to 0.7 which stopped it from crashing but there was still chatter in the logs (so then I actually fixed the generator :)). But this seemed worth mentioning.

bhollis commented 10 years ago

Fixed in master. Thanks for reporting!