Skip to content

Conversation

@mscolnick
Copy link
Contributor

@mscolnick mscolnick commented Nov 5, 2025

This traversed <img src elements and replaces virtual files ./@file/foo.png with the file and data-uri, so these HTML files can be more self-contained

@mscolnick mscolnick requested a review from dmadisetti as a code owner November 5, 2025 18:21
buffer = virtual_file.buffer
# Skip adding if buffer is empty
if len(buffer) == 0:
return
Copy link
Contributor Author

@mscolnick mscolnick Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previous bug that would log an unnecessary error

@vercel
Copy link

vercel bot commented Nov 5, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
marimo-docs Ready Ready Preview Comment Nov 6, 2025 9:40pm

LOGGER = _loggers.marimo_logger()


class _HTMLAttributeReplacer(HTMLParser):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprised you had to roll your own here

from nbformat.notebooknode import NotebookNode # type: ignore

VIRTUAL_FILE_ALLOWED_ATTRIBUTES = {"src"}
VIRTUAL_FILE_ALLOWED_TAGS = {"img"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A previous version of this allowed video / audio tags as well. Is that not worth it too large? Might be worth putting a comment at least

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea i didn't want to shove those in here. i can add a comment

dmadisetti
dmadisetti previously approved these changes Nov 6, 2025
Copy link
Collaborator

@dmadisetti dmadisetti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if we could delegate some of the sanitization stuff- but this is an OK stop gap otherwise

@mscolnick mscolnick merged commit 2f8f8ad into main Nov 6, 2025
35 of 41 checks passed
@mscolnick mscolnick deleted the ms/inline-image-exports branch November 6, 2025 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants