Open Vagab opened 4 months ago
It seems like this would be very non-trivial to implement. Zed uses its own customer renderer so they'd have to make a LaTeX renderer that produces something like MathElement
. I didn't dig super deep into that side of the equation but think that once that is done it would be relatively easy to regex match for $
enclosed text and render MathElement
as part of the render_markdown_text
sequence that currently calculates highlights and generates interactive text elements for hyperlinks.
pulldown-cmark
added support for it so should be easy on the parsing front. Rendering Layout is a lot more complicated, the only potentially useful reference I've found is typst's implementation.
Just to give an idea of what this might look like (screenshot from the VS Code Markdown Preview extension).
The markup:
1.11 Neptunium. In the fall of 2002, a group of scientists at Los Alamos National Laboratory determined
that the critical mass of neptunium-237 is about 60 kg. The critical mass of a fissionable material is the
minimum amount that must be brought together to start a chain reaction. This element has a density of
19.5 g/cm^3. What would be the radius of a sphere of this material that has a critical mass?
Volume of the critical sphere $$ V_{crit} = 60,000 / 19.5 = 3077cm^3 = \frac{4\pi r^3}{3} $$
So
$$ R_{crit} = \sqrt[3]{\frac{3 \times 3077}{4 \pi}} = 9cm \; ✅ $$
Rendering:
Check for existing issues
Describe the feature
Would be cool if markdown preview rendered math as well
If applicable, add mockups / screenshots to help present your vision of the feature
No response