If I do
julia> using Markdown
julia> str = md"""
hi
```
1 + 1
```
""";
then display
will print the markdown string in a nice way:
image.png
but print
and show
and friends all fail to do it:
image.png
Is there a way to do this without display
? I need to specify a specific output stream, which you can't do with display
.
cc @Timothy since I suspect you're the expert on this
Markdown.term
I think?
Yep! Markdown.term(::IO, ::Markdown.MD)
is what you want.
ah cool. It'd be good if this was documented then
Yea. Reminds me, I really should get a move on with checkdoc
...
in particular, does Markdown.term
fail gracefully if io
doesn't support fancy outputs?
actually, why is that the bevhaviour of show
for markdown objects? seems like the show method should check the output streams capabilities (just color is probably enough), no?
in particular, does Markdown.term fail gracefully if io doesn't support fancy outputs?
Yes
very annoying, since show
is supposed to be the function that does that
IMO it should behave like you expect
In any case, thanks both of you!
Mason Protter has marked this topic as resolved.
This is what it was getting used for btw, in case anyone is curious: https://github.com/JuliaObjects/Accessors.jl/pull/140
It's nice to have markdown formatting for register_error_hint
.
I was curious :)
I think that use of Experimental API isn't quite right though IIRC
I think the version check should be replaced with a isdefined(Base.Experimental, :register_error_hint)
check
The version check was there because I was trying to avoid a failure on 1.6. The original PR did the isdefined
but then it turned out the failure was something else, so I've now switched it back.
By the way Timothy, since you're looking at it, do you have thoughts on the hint itself? I know you advocated in your manifesto-in-progress for using error codes so people can look up more elaborate descriptions of errors, do you think this is case that'd be better off with an error code or documentation link?
I feel like much of the benefit with error codes is when they're a standard/ubiquitous system. I'm looking forward to that day, but until we get there I think your current approach is probably the best option. My 2c.
As an aside, I love to see the effort you've gone to in creating a properly helpful error message there :heart:
Well I did it because I was thinking of your document
Last updated: Nov 06 2024 at 04:40 UTC