Markdown inconsistency: PlutoUI, latexifications

I’ve previously solved the issue of interpolating latexified expressions in Pluto by using Markdown.parse() rather than md"". But rather unsatisfyingly, the opposite compatibilty constraints apply to PlutoUI elements:

using Latexify
md"""
$(Slider(1:5))
$(@latexify x^2)
"""

Here the slider displays correctly, but the latexified string displays as L"$x^2$".

Markdown.parse("""
$(Slider(1:5))
$(@latexify x^2)
""")

Here the latexified string is displayed correctly, but the slider is shown as PlutoUI.BuiltinsNotebook.Slider{Int64}(1:5, 1, false).

Has anyone found a workaround that works for both at the same time (preferably without having to concatenate different strings)?

x_str = @latexify x^2
md"""
$x_str
"""

works, so I’m not sure what is going on.

The starting point for your investigation could be the definition of the md"…" string definition:

https://github.com/JuliaLang/julia/blob/a761cc0b82f88838eb31b29e7387cea35a0cab30/stdlib/Markdown/src/Markdown.jl#L43