Closed c42f closed 4 years ago
It's unfortunate that multi-line highlighting does not work...
I guess an easy solution may be to tweak Markdown.jl so that it prints ANSI escape code for each line?:
julia> sprint(
show,
"text/plain",
Markdown.parse("`" * "aaa "^20 * "`"),
context = IOContext(stdout, :displaysize => (30, 30)),
)
" \e[36maaa aaa aaa aaa aaa aaa\n aaa aaa aaa aaa aaa aaa\n aaa aaa aaa aaa aaa aaa\n aaa aaa\e[39m"
It looks like printstyled
is doing this:
julia> sprint(io -> printstyled(io, " AAA \n BBB \n CCC", color = :red), context = :color => true)
"\e[31m AAA \e[39m\n\e[31m BBB \e[39m\n\e[31m CCC\e[39m"
So it's probably that Markdown.jl is not using printstyled
?
It's unfortunate that multi-line highlighting does not work
Yes this sure is annoying. Working around it seems to require ANSI code parsing and having a model of the terminal's internal color state. At that point it might be better to give up and fix upstream + vendor Markdown.term()
though.
Thanks for the review!
Fixes #16.
As suggested there, I'm now using
show(io, MIME"text/plain"(), message)
by default (except for strings, which go throughMarkdown.parse()
first. With that in mind it might be sensible to tweak the API requirements formessage
again, revisiting whethershow
orstring
are used.