posit-dev / posit-dev/positron

Enable text/html + isolated: true mime type in Positron Notebook Editor

Open
#12,686 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: notebooks-jupyter
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:

  1. the code cell disappears
  2. the output shows the following error message
Image

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 &lt;iframe&gt; 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

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.