8000 A few different MIME types don't work · Issue #767 · pyscript/pyscript · GitHub
[go: up one dir, main page]

Skip to content

A few different MIME types don't work #767

@marimeireles

Description

@marimeireles

Checklist

  • I added a descriptive title
  • I searched for other issues and couldn't find a solution or duplication
  • I already searched in Google and didn't find any good information or help

What happened?

Here you can see our current methods:

MIME_METHODS = {
    "__repr__": "text/plain",
    "_repr_html_": "text/html",
    "_repr_markdown_": "text/markdown",
    "_repr_svg_": "image/svg+xml",
    "_repr_png_": "image/png",
    "_repr_pdf_": "application/pdf",
    "_repr_jpeg_": "image/jpeg",
    "_repr_latex": "text/latex",
    "_repr_json_": "application/json",
    "_repr_javascript_": "application/javascript",
    "savefig": "image/png",
}

And their implementation:

MIME_RENDERERS = {
    "text/plain": identity,
    "text/html": identity,
    "image/png": lambda value, meta: render_image("image/png", value, meta),
    "image/jpeg": lambda value, meta: render_image("image/jpeg", value, meta),
    "image/svg+xml": identity,
    "application/json": identity,
    "application/javascript": lambda value, meta: f"<script>{value}</script>",
}

As you can see not all of them map to an implementation which makes them not possible to use (? maybe I'm missing something here)

We either have to fix it or... Completely change the way we implement these.
Antonio's input was that we should have an API that allows users to expand on these and I agree. For example, it seems like numpy has a specific way of displaying arrays that we don't cover. This advice came from one of Jupyter Lab's main contributor "wishing they had made it different".

Antonio can probably unpack this better as he's the one leading the refactoring.

What browsers are you seeing the problem on? (if applicable)

No response

Console info

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlogissue has been triaged but has not been earmarked for any upcoming releasetype: bugSomething isn't working

    Type

    No type

    Projects

    Status

    Next

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0