New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Picture-generating blocks #307
Comments
Please also keep in mind animated images like GIF (though it's better to let it go in 2020 already!), WebP, AVIF or WebM blocks. |
One idea I've had about this is around graphs and other visualizations. You could imagine capturing the raw data backing a graph in the text of the mdx (which can then get committed to your source repo), and then being able to convert this into a proper visualization, either in a properly equipped editor (like vscode?) or in web-output. That way, diffs that affected the data could be meaningfully viewed with an ordinary textual diff program, which could be quite useful for various kinds of number-crunching applications. |
An HTML element ( |
I'm not sure it is in the scope of mdx, as mdx focuses on executable blocks, and not on rendering the graphic contents of markdown files, is it not possible to pipe mdx with another rendering tool? |
😲 |
I think @gpetiot is right, it feels like this is out of the scope of MDX. What we could eventually consider to make it easier to implement such an independent tool is to extract bits of MDX parsing logic into a small library. We already considered this for formatting related issues. |
Following the discussion on discord, I'm opening a discussion to see if mdx could be extended to support graphic outputs. I have prototyped a tool that reads a markdown file with ocaml blocks and produces an html file with toplevel outputs + rendered pictures in the document. My goal here is to see if I can help providing a similar functionality in mdx.
I have to admit it's not totally clear to me how this feature would fit with how mdx works currently. First question is, would that feature make sense in the pp and test modes? Or would it be better to include it only in a new mode (like the jupyter notebook output, or a new mode for markdown to markdown transformation)?
Also, what would the API for picture rendering? How should pictures be rendered in the final document? In my prototype I started using the
install_printer
directive of the toplevel to install a printer for a dedicated image type. The printer would render values of this type as HTMLimg
elements with embedded data using ansrc
attribute of the formsrc="data:image/png;base64 ..."
. Registering a printer is however not very appropriate, notably because the image values are also rendered as HTML when they appear within a list for instance, and this is then pretty useless and inconvenient. I implemented another mechanism where one explicitly calls ashow
function to have a picture rendered in the document, and the picture is interleaved with toplevel output. The implementation is less pretty than the output though, as it relies on side effects and a call toObj.magic
... There are certainly better ways to proceed.Let me know your opinion, and tell me if I can help in some way or another.
The text was updated successfully, but these errors were encountered: