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

Markdown: Allow tabs instead of spaces in footnote and admonition (#37335) #37347

Merged
merged 1 commit into from
Sep 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions stdlib/Markdown/src/Common/block.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function footnote(stream::IO, block::MD)
buffer = IOBuffer()
write(buffer, readline(stream, keep=true))
while !eof(stream)
if startswith(stream, " ")
if startswith(stream, " ") || startswith(stream, "\t")
write(buffer, readline(stream, keep=true))
elseif blankline(stream)
write(buffer, '\n')
Expand Down Expand Up @@ -224,10 +224,10 @@ function admonition(stream::IO, block::MD)
return false
end
end
# Consume the following indented (4 spaces) block.
# Consume the following indented (4 spaces or tab) block.
buffer = IOBuffer()
while !eof(stream)
if startswith(stream, " ")
if startswith(stream, " ") || startswith(stream, "\t")
write(buffer, readline(stream, keep=true))
elseif blankline(stream)
write(buffer, '\n')
Expand Down
15 changes: 14 additions & 1 deletion stdlib/Markdown/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ let text =

And *another* paragraph.

\tAnd a third paragraph indented with a *tab*.

This isn't part of the footnote.
""",
md = Markdown.parse(text)
Expand All @@ -97,7 +99,7 @@ let text =
@test md.content[2].id == "1"
@test md.content[3].id == "note"

@test length(md.content[3].text) == 4
@test length(md.content[3].text) == 5

let expected =
"""
Expand All @@ -116,6 +118,8 @@ let text =

And *another* paragraph.

And a third paragraph indented with a *tab*.


This isn't part of the footnote.
"""
Expand All @@ -138,6 +142,8 @@ let text =

And *another* paragraph.

And a third paragraph indented with a *tab*.


This isn't part of the footnote.
"""
Expand Down Expand Up @@ -671,6 +677,8 @@ let t_1 =
!!! note
foo bar baz

\tsecond tab-indented paragraph

!!! warning "custom title"
- foo
- bar
Expand Down Expand Up @@ -714,6 +722,7 @@ let t_1 =
@test m_2.content[1].category == "note"
@test m_2.content[1].title == "Note"
@test isa(m_2.content[1].content[1], Markdown.Paragraph)
@test isa(m_2.content[1].content[2], Markdown.Paragraph)

@test isa(m_2.content[2], Markdown.Admonition)
@test m_2.content[2].category == "warning"
Expand Down Expand Up @@ -810,6 +819,8 @@ let t_1 =
!!! note
foo bar baz

second tab-indented paragraph


!!! warning "custom title"
* foo
Expand Down Expand Up @@ -839,6 +850,8 @@ let t_1 =
.. note::
foo bar baz

second tab-indented paragraph


.. warning:: custom title
* foo
Expand Down