posit-dev / posit-dev/positron
Enable text/html + isolated: true mime type in Positron Notebook Editor
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.3k
- Forks
- 184
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 195
Description
Context
text/html + isolated: true is used for Voilà dashboards and any output with self-contained CSS/JS.
It's important to have isolated=true to prevent styling bleeding into the entire notebook
Running the following code:
- the code cell disappears
- the output shows the following error message
Code
# text/html with metadata isolated: true — should render inside an <iframe>
from IPython.core.display import DisplayObject
class IsolatedHTML(DisplayObject):
"""HTML output with isolated metadata flag set to True."""
def _repr_mimebundle_(self, **kwargs):
html_content = """
<html>
<head><style>body { font-family: sans-serif; background: #f0f8ff; padding: 1em; }</style></head>
<body>
<h3>Isolated HTML (text/html + metadata.isolated=true)</h3>
<p>This should render inside an <iframe> to isolate its styles and scripts.</p>
<p style="color: darkgreen; font-weight: bold;">Isolation test: styles here should NOT leak to parent page.</p>
</body>
</html>
"""
return (
{"text/html": html_content, "text/plain": "text/html isolated test"},
{"isolated": True} # metadata dict — second element of the tuple
)
display(IsolatedHTML())
Acceptance criteria
Expect the following code to render properly with the html changes isolated to the cell
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the Positron Notebook Editor's MIME-output rendering path and reproduce the issue with the provided IsolatedHTML example. Check how text/html metadata is handled, then verify that isolated output renders in an iframe without affecting the notebook page or disappearing with the code cell. Confirm the acceptance screenshots' behavior after the change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100