Skip to content
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

Support text/vnd.mermaid MIME Type in Formatters #7175

Open
IntegerMan opened this issue Jun 15, 2024 · 0 comments
Open

Support text/vnd.mermaid MIME Type in Formatters #7175

IntegerMan opened this issue Jun 15, 2024 · 0 comments
Labels
enhancement New feature or request untriaged New issue has not been triaged

Comments

@IntegerMan
Copy link

Is your feature request related to a problem? Please describe.
I'd like to be able to easily write formatters for built-in and custom types that use Mermaid markdown to render a custom diagram for an object. My specific case in wanting this at the moment is a Microsoft.ML.ITransformer object where I want to visualize the chain of transformers from a machine learning model.

I can generate a valid mermaid string, but outputting it from a Formatter either results in the mermaid string appearing as text if plain text or HTML mime types are used, or with my formatter not being used at all if I specify "text/markdown" or "text/vnd.mermaid" (Mermaid's official MIME type).

There are ways of manually passing things off to the Mermaid kernel via extensions, but those are a lot more work than a simple Formatter, and it'd be ideal to avoid having to write a magic command just to process something.

Describe the solution you'd like
Formatters with a MIME type of text/vnd.mermaid should have their output piped to the Mermaid kernel and the result of that operation should be rendered below the cell when the formatter is in use.

You should be able to set up a formatter in a manner like this:

Formatter.Register<ITransformer>((transformer, writer) =>
{
    writer.Write(MattEland.ML.Interactive.TransformerExtensions.ToMermaid(transformer));
}, "text/vnd.mermaid");

Describe alternatives you've considered
I've considered finding an external rendering library to transform mermaid to a supported MIME type, writing a custom magic command to connect things directly to the Mermaid kernel, and considered avoiding Mermaid entirely here and building something in SVG.

Additional context
This is part of a larger effort I'm making to try to improve the data analysis and data science workflow in a Polyglot Notebook based on things I've observed in book / course creation and while using this toolset pursuing my master's degree.

See https://github.com/IntegerMan/MattEland.ML/blob/main/MattEland.ML/MattEland.ML.Interactive/TransformerExtensions.cs and neighboring files for details on my early transformer mermaid visualization attempt.

@IntegerMan IntegerMan added the enhancement New feature or request label Jun 15, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged label Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request untriaged New issue has not been triaged
Projects
None yet
Development

No branches or pull requests

1 participant