Skip to content

Commit

Permalink
Do not print at-ref links in terminal (JuliaLang#25132)
Browse files Browse the repository at this point in the history
* Do not print at-ref links.

* Also handle `at-ref param` links
  • Loading branch information
helgee authored and fredrikekre committed Dec 16, 2017
1 parent 378e102 commit fbbdaeb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion base/markdown/render/terminal/render.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ term(io::IO, x, _) = show(io, MIME"text/plain"(), x)

terminline(md) = sprint(terminline, md)

terminline(io::IO, content...) = terminline(io, collect(content))

function terminline(io::IO, content::Vector)
for md in content
terminline(io, md)
Expand Down Expand Up @@ -134,7 +136,9 @@ end
terminline(io::IO, f::Footnote) = with_output_format(:bold, terminline, io, "[^$(f.id)]")

function terminline(io::IO, md::Link)
terminline(io, "$(terminline(md.text)) ($(md.url))")
url = !Base.startswith(md.url, "@ref") ? " ($(md.url))" : ""
text = terminline(md.text)
terminline(io, text, url)
end

function terminline(io::IO, code::Code)
Expand Down
2 changes: 2 additions & 0 deletions test/markdown.jl
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ World""" |> plain == "Hello\n\n---\n\nWorld\n"
# multiple whitespace is ignored
@test sprint(term, md"a b") == " a b\n"
@test sprint(term, md"[x](https://julialang.org)") == " x (https://julialang.org)\n"
@test sprint(term, md"[x](@ref)") == " x\n"
@test sprint(term, md"[x](@ref something)") == " x\n"
@test sprint(term, md"![x](https://julialang.org)") == " (Image: x)\n"

# enumeration is normalized
Expand Down

0 comments on commit fbbdaeb

Please sign in to comment.