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

A few different MIME types don't work #767

Open
3 tasks done
Tracked by #622
marimeireles opened this issue Sep 14, 2022 · 1 comment
Open
3 tasks done
Tracked by #622

A few different MIME types don't work #767

marimeireles opened this issue Sep 14, 2022 · 1 comment
Labels
backlog issue has been triaged but has not been earmarked for any upcoming release type: bug Something isn't working

Comments

@marimeireles
Copy link
Member

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

@marimeireles marimeireles added type: bug Something isn't working needs-triage Issue needs triage labels Sep 14, 2022
@marimeireles marimeireles added backlog issue has been triaged but has not been earmarked for any upcoming release and removed needs-triage Issue needs triage labels Oct 4, 2022
@marimeireles
Copy link
Member Author

We should also add more tests for the ones that work but don't have tests:
https://github.com/pyscript/pyscript/blob/main/pyscriptjs/tests/py-unit/test_pyscript.py
I'd guess png, jpg, svg prbb works?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog issue has been triaged but has not been earmarked for any upcoming release type: bug Something isn't working
Projects
Status: Next
Development

No branches or pull requests

1 participant