I’m looking for a way to produce rich text easily in Makie
plots.
I know LaTeX strings work in Makie: this thread. But the LaTeX font (Computer Modern) is less legible than Makie
’s default one. Its rich text produces more pleasant results, and it seems impossible to switch to a sans-serif font for LaTeXStrings
. See this thread.
Currently, I end up kind of building my ad-hoc tools:
using Makie
function Base.:*(x::Makie.RichText, y::Makie.RichText)
rich(x, y)
end
function Base.:*(x::Makie.RichText, y::AbstractString)
rich(x, y)
end
function Base.:*(x::AbstractString, y::Makie.RichText)
rich(x, y)
end
itl(s) = rich(s, font=:italic)
paren(s) = "(" * s * ")"
ylabel = itl("c") * superscript(paren(itl("n"))) * " [m/s]"
In this example, I build the rich text « c(n) [m/s] », which in markdown is
*c*<sup>(*n*)</sup> [m/s]
which is much nicer to write. So, I imagine one could write a converter from (a subset of ) markdown to rich text, which you could use as ylabel = md2rich("*c*<sup>(*n*)</sup> [m/s]")
.
First of all, I don’t know whether this rich text capability is part of Makie
or it is an independent library. If the latter is the case, is there a converter from, say, a subset of markdown to rich text?
Searching this forum, I’ve seen threads about converting markdown to HTML . . .