Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions rich/jupyter.py
Original file line number Diff line number Diff line change
@@ -26,10 +26,18 @@ def _repr_mimebundle_(
self, include: Sequence[str], exclude: Sequence[str], **kwargs: Any
) -> Dict[str, str]:
data = {"text/plain": self.text, "text/html": self.html}

# Check if we need to filter by include
if include:
data = {k: v for (k, v) in data.items() if k in include}
data = {k: data[k] for k in data if k in include}
# Early return if there's nothing to exclude
if not exclude:
return data

# Check if we need to filter by exclude
if exclude:
data = {k: v for (k, v) in data.items() if k not in exclude}
data = {k: data[k] for k in data if k not in exclude}

return data