Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:lax_spacing with lists #311

Closed
firien opened this issue Sep 17, 2013 · 0 comments · Fixed by #324
Closed

:lax_spacing with lists #311

firien opened this issue Sep 17, 2013 · 0 comments · Fixed by #324
Labels
Milestone

Comments

@firien
Copy link

firien commented Sep 17, 2013

This renders OK (using v3):

require 'redcarpet'
md = %{
this is an **unordered** list:

* an item
* another item

this is an **ordered** list:

1. first
2. second

coda
}

renderer = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new)
puts renderer.render md

but trim some newlines and use the lax_spacing option and the second list is wrapped in a <p> tag:
update: GitHub also renders the second list in a <p> tag

md = %{
this is an **unordered** list:
* an item
* another item

this is an **ordered** list:
1. first
2. second

coda
}

renderer = Redcarpet::Markdown.new(
  Redcarpet::Render::HTML.new,
  lax_spacing: true
)
puts renderer.render md
=begin
<p>this is an <strong>unordered</strong> list:</p>

<ul>
<li>an item</li>
<li>another item</li>
</ul>

<p>this is an <strong>ordered</strong> list:
1. first
2. second</p>

<p>coda</p>
=end

pad the numbered list with leading spaces and it renders OK again, is this how it is supposed to work?

md = %{
this is an **unordered** list:
* an item
* another item

this is an **ordered** list:
 1. first
 2. second

coda
}

renderer = Redcarpet::Markdown.new(
  Redcarpet::Render::HTML.new,
  lax_spacing: true
)
puts renderer.render md
=begin
<p>this is an <strong>unordered</strong> list:</p>

<ul>
<li>an item</li>
<li>another item</li>
</ul>

<p>this is an <strong>ordered</strong> list:</p>

<ol>
<li>first</li>
<li>second</li>
</ol>

<p>coda</p>
=end
robin850 added a commit that referenced this issue Nov 11, 2013
Previously, enabling the `:lax_spacing` option, if a paragraph was
followed by an ordered list it was previously unparsed and was part
of the paragraph but this is no more the case.

The fix is pretty straightforward, since the `parse_paragraph` method
was checking through the `isalnum` function whether the first char on
the next line was alpha-numeric but ordered list start with numerics,
we just need to substitute the function with isalpha.

Fixes #311
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant