Oh, I see the problem: the Base.Markdown module overrides Base.display(d::Base.REPL.REPLDisplay, md::MD). Probably it shouldn’t do this: it should use the IOContext properties in show to decide whether to use terminal formatting codes (in the same way that we should use these properties to decide whether to print ANSI color codes).
(I’m guessing that this code for Markdown display pre-dates the whole IOContext stuff.)
Update: fixed by #25067.