Empty line in script block throws exception #42

Closed
ccaum opened this Issue Dec 15, 2011 · 4 comments

3 participants

@ccaum
ccaum commented Dec 15, 2011

When parsing the following markdown:

  hash = { 
    'key' => 'value'
  }

  use_hash hash

I get this exception thrown due to the empty line.:

| Maruku tells you:
+---------------------------------------------------------------------------
| String finished while reading (break on []) already read: "ruby\n  hash = {\n    'key' => 'value'\n  }"
| ---------------------------------------------------------------------------
| ```rubyN  hash = {N    'key' => 'value'N  }EOF
| -------------------------------------------|--------------------------------
|                                            +--- Byte 43
| Shown bytes [0 to 43] of 43:
| >```ruby
| >  hash = {
| >    'key' => 'value'
| >  }
| 
| At line 5
|       text     |  hash = {|
|       code     |    'key' => 'value'|
|       text     |  }|
|      empty --> ||
|       text     |  use_hash hash|
|       text     |```|
+---------------------------------------------------------------------------
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/errors_management.rb:49:in `maruku_error'
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:402:in `read_simple'
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:521:in `read_inline_code'
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:89:in `read_span'
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:46:in `parse_span_better'
\___________________________________________________________________________

 ___________________________________________________________________________
| Maruku tells you:
+---------------------------------------------------------------------------
| I boldly continue
| ---------------------------------------------------------------------------
| ```rubyN  hash = {N    'key' => 'value'N  }EOF
| -------------------------------------------|--------------------------------
|                                            +--- Byte 43
| Shown bytes [0 to 43] of 43:
| >```ruby
| >  hash = {
| >    'key' => 'value'
| >  }
| 
| At line 5
|       text     |  hash = {|
|       code     |    'key' => 'value'|
|       text     |  }|
|      empty --> ||
|       text     |  use_hash hash|
|       text     |```|
+---------------------------------------------------------------------------
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/errors_management.rb:56:in `maruku_recover'
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:403:in `read_simple'
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:521:in `read_inline_code'
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:89:in `read_span'
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:46:in `parse_span_better'
\___________________________________________________________________________

 ___________________________________________________________________________
| Maruku tells you:
+---------------------------------------------------------------------------
| String finished while reading (break on []) already read: ""
| ---------------------------------------------------------------------------
|   use_hash hashN```EOF
| -------------------|--------------------------------------------------------
|                    +--- Byte 19
| Shown bytes [0 to 19] of 19:
| >  use_hash hash
| >```
| 
| At line 8
|      empty     ||
|       text     |  use_hash hash|
|       text     |```|
+---------------------------------------------------------------------------
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/errors_management.rb:49:in `maruku_error'
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:402:in `read_simple'
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:521:in `read_inline_code'
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:89:in `read_span'
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:46:in `parse_span_better'
\___________________________________________________________________________

 ___________________________________________________________________________
| Maruku tells you:
+---------------------------------------------------------------------------
| I boldly continue
```ruby
| ---------------------------------------------------------------------------
|   use_hash hashN```EOF
| -------------------|--------------------------------------------------------
|                    +--- Byte 19
| Shown bytes [0 to 19] of 19:
| >  use_hash hash
| >```
| 
| At line 8
|      empty     ||
|       text     |  use_hash hash|
|       text     |```|
+---------------------------------------------------------------------------
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/errors_management.rb:56:in `maruku_recover'
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:403:in `read_simple'
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:521:in `read_inline_code'
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:89:in `read_span'
!/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:46:in `parse_span_better'
\___________________________________________________________________________
/usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:528:in `read_inline_code': undefined method `[]' for nil:NilClass (NoMethodError)
    from /usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:89:in `read_span'
    from /usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:46:in `parse_span_better'
    from /usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_span_better.rb:36:in `parse_lines_as_span'
    from /usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_block.rb:275:in `read_paragraph'
    from /usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_block.rb:158:in `read_text_material'
    from /usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_block.rb:69:in `parse_blocks'
    from /usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_block.rb:41:in `parse_text_as_markdown'
    from /usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/input/parse_doc.rb:57:in `parse_doc'
    from /usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/maruku.rb:30:in `initialize'
    from /usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/bin/maruku:113:in `new'
    from /usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/bin/maruku:113
    from /usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/bin/maruku:106:in `each'
    from /usr/lib/ruby/gems/1.8/gems/maruku-0.6.0/bin/maruku:106
    from /usr/bin/maruku:19:in `load'
    from /usr/bin/maruku:19
Collaborator
distler commented Jun 16, 2012

Backticks (including multiple backticks) create inline code: x+5<code>x+5</code>. They do not create code blocks. And, as you'd expect, they don't support inserting blank line. This is true, both in Maruku and in the original Markdown.

If you want code blocks in Maruku, you need to use either indented code blocks or, if you are using a version of Maruku which supports it, fenced code blocks.

Owner
bhollis commented Jul 31, 2012

Closing this in favor of #28, which is to fully support fenced code blocks.

@bhollis bhollis closed this Jul 31, 2012
Collaborator
distler commented Jul 31, 2012

My Nokogiri branch (which I thought you already merged) already supports fenced code blocks, by default.

Owner
bhollis commented Jul 31, 2012

Yes, it supports tilde-style fenced code blocks, but not GitHub-style backtick code blocks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment