Skip to content

Commit

Permalink
Don't require blank line before markdown lists
Browse files Browse the repository at this point in the history
Fixes #11249 to follow the CommonMark spec for lists which does not
require a blank line prior to the start of a list.
  • Loading branch information
MichaelHatherly committed Aug 24, 2016
1 parent 941fa26 commit d8da082
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/markdown/Common/block.jl
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ isordered(list::List) = list.ordered >= 0
const BULLETS = r"^ {0,3}(\*|\+|-)( |$)"
const NUM_OR_BULLETS = r"^ {0,3}(\*|\+|-|\d+(\.|\)))( |$)"

@breaking true ->
function list(stream::IO, block::MD)
withstream(stream) do
bullet = startswith(stream, NUM_OR_BULLETS; eat = false)
Expand Down
27 changes: 27 additions & 0 deletions test/markdown.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,33 @@ let doc = md"""
@test doc.content[2].items[3][1].content[1] == "zombie"
end

let doc = Markdown.parse(
"""
A paragraph...
- one
- two
* three
* four
... another paragraph.
"""
)

@test length(doc.content) === 3
@test isa(doc.content[1], Markdown.Paragraph)
@test isa(doc.content[2], Markdown.List)
@test isa(doc.content[3], Markdown.Paragraph)

@test length(doc.content[2].items) === 2
@test doc.content[2].items[1][1].content[1] == "one"
@test length(doc.content[2].items[2]) == 2
@test doc.content[2].items[2][1].content[1] == "two"

@test isa(doc.content[2].items[2][2], Markdown.List)
@test length(doc.content[2].items[2][2].items) === 2
@test doc.content[2].items[2][2].items[1][1].content[1] == "three"
@test doc.content[2].items[2][2].items[2][1].content[1] == "four"
end

@test md"Foo [bar]" == MD(Paragraph("Foo [bar]"))
@test md"Foo [bar](baz)" != MD(Paragraph("Foo [bar](baz)"))
@test md"Foo \[bar](baz)" == MD(Paragraph("Foo [bar](baz)"))
Expand Down

0 comments on commit d8da082

Please sign in to comment.