Skip to content

Commit

Permalink
Remove traling newline in Markdown code blocks (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
Keluaa authored Jun 29, 2024
1 parent b0071f5 commit 249d075
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/MarkdownHighlighter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function Markdown.term(io::IO, md::Markdown.Code, columns)
end

if do_syntax && HIGHLIGHT_MARKDOWN[]
for (sourcecode, output) in zip(sourcecodes, outputs)
for (i, (sourcecode, output)) in enumerate(zip(sourcecodes, outputs))
tokens = collect(tokenize(sourcecode))
crayons = fill(Crayon(), length(tokens))
SYNTAX_HIGHLIGHTER_SETTINGS(crayons, tokens, 0, sourcecode)
Expand All @@ -52,16 +52,20 @@ function Markdown.term(io::IO, md::Markdown.Code, columns)
print(buff, output)

str = String(take!(buff))
for line in Markdown.lines(str)
print(io, " "^Markdown.margin)
println(io, line)
lines = Markdown.lines(str)
for li in eachindex(lines)
print(io, " "^Markdown.margin, lines[li])
li < lastindex(lines) && println(io)
end

i < lastindex(sourcecodes) && println(io)
end
else
Base.with_output_color(:cyan, io) do io
for line in Markdown.lines(md.code)
print(io, " "^Markdown.margin)
println(io, line)
lines = Markdown.lines(md.code)
for i in eachindex(lines)
print(io, " "^Markdown.margin, lines[i])
i < lastindex(lines) && println(io)
end
end
end
Expand Down

0 comments on commit 249d075

Please sign in to comment.