Zaid-Ajaj / Feliz

A fresh retake of the React API in Fable and a collection of high-quality components to build React applications in F#, optimized for happiness
https://zaid-ajaj.github.io/Feliz/
MIT License
531 stars 77 forks source link

Feliz.Markdown plug-in support #572

Open dgrimmin opened 1 year ago

dgrimmin commented 1 year ago

Dear Zaid,

For some time now, I have been thinking about how to render math with Feliz.Markdown. I got my inspiration from https://levelup.gitconnected.com/adding-katex-and-markdown-in-react-7b70694004ef . Could you comment on the way to achieve this?

All the best, Dennis

Zaid-Ajaj commented 1 year ago

Hi @dgrimmin I've looked briefly at the article. I think it is already doable with Feliz.Markdown because you can override how elements are rendered to ReactElement using markdown.components.{<elementRenderer>} where elementRenderer is a function that takes information about the element and let's you choose what ReactElement to render.

dgrimmin commented 1 year ago

Thank you for your time Zaid.

This reminds me of a part of the source code of your Feliz website, where you have a part named codeBlockRenderer. That is basically the part that needs to be adapted for the rendering is what you are saying if I understand correctly. How would you go about instructing that part of your code to translate the raw text to math react-style? Would it require writing bindings for Katex?