Skip to content

Commit

Permalink
fix check for level < 1 in Markdown header (#22087)
Browse files Browse the repository at this point in the history
* fix check for level < 1 in header
  • Loading branch information
KristofferC committed Apr 5, 2018
1 parent d590bb1 commit 8bb878d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 39 deletions.
2 changes: 1 addition & 1 deletion stdlib/Markdown/src/Common/block.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function hashheader(stream::IO, md::MD)
eatindent(stream) || return false
level = 0
while startswith(stream, '#') level += 1 end
level < 1 || level > 6 && return false
(level < 1 || level > 6) && return false

c = ' '
# Allow empty headers, but require a space
Expand Down
40 changes: 2 additions & 38 deletions stdlib/Markdown/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1066,41 +1066,5 @@ let text =
end
end

# different output depending on whether color is requested:
let buf = IOBuffer()
show(buf, "text/plain", md"*emph*")
@test String(take!(buf)) == " emph\n"
show(buf, "text/markdown", md"*emph*")
@test String(take!(buf)) == "*emph*\n"
show(IOContext(buf, :color=>true), "text/plain", md"*emph*")
@test String(take!(buf)) == " \e[4memph\e[24m\n"
end

# table rendering with term #25213
t = """
a | b
:-- | --:
1 | 2"""
@test sprint(Markdown.term, Markdown.parse(t), 0) == "a b\n– –\n1 2\n"

# test Base.copy
let
md = doc"test"
md′ = copy(md)
@test length(md) == length(md′) == 1
push!(md, "new")
@test length(md) == 2
@test length(md′) == 1

@test !haskey(md.meta, :foo)
md.meta[:foo] = 42
@test !haskey(md′.meta, :foo)
end

let
v = Markdown.parse("foo\n\n- 1\n- 2\n\n- 3\n\n\n- 1\n- 2\n\nbar\n\n- 1\n\n 2\n- 4\n\nbuz\n\n- 1\n- 2\n 3\n- 4\n")
@test v.content[2].loose
@test !v.content[3].loose
@test v.content[5].loose
@test !v.content[7].loose
end
# issue 20225, check this can print
@test typeof(sprint(Markdown.term, Markdown.parse(" "))) == String

0 comments on commit 8bb878d

Please sign in to comment.