Skip to content

Commit dd29133

Browse files
committed
discard matplotlib, seaborn, and plotnine intermediates
1 parent 1bfb7d1 commit dd29133

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/core/jupyter/jupyter.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,15 +1110,10 @@ async function mdFromCodeCell(
11101110
}
11111111

11121112
// filter matplotlib intermediate vars
1113-
if (output.output_type === "execute_result") {
1114-
const textPlain = (output as JupyterOutputDisplayData).data
1115-
?.[kTextPlain] as string[] | undefined;
1116-
if (
1117-
textPlain && textPlain.length && textPlain[0].startsWith("[<matplotlib")
1118-
) {
1119-
return false;
1120-
}
1113+
if (isDiscadableTextExecuteResult(output)) {
1114+
return false;
11211115
}
1116+
11221117
return true;
11231118
}).map((output) => {
11241119
// convert text/latex math to markdown as appropriate
@@ -1514,6 +1509,21 @@ async function mdFromCodeCell(
15141509
return md;
15151510
}
15161511

1512+
function isDiscadableTextExecuteResult(output: JupyterOutput) {
1513+
if (output.output_type === "execute_result") {
1514+
const textPlain = (output as JupyterOutputDisplayData).data
1515+
?.[kTextPlain] as string[] | undefined;
1516+
if (textPlain && textPlain.length) {
1517+
return [
1518+
"[<matplotlib",
1519+
"<seaborn.",
1520+
"<ggplot:",
1521+
].some((startsWith) => textPlain[0].startsWith(startsWith));
1522+
}
1523+
}
1524+
return false;
1525+
}
1526+
15171527
function hasLayoutOptions(cell: JupyterCellWithOptions) {
15181528
return Object.keys(cell.options).some((key) => key.startsWith("layout"));
15191529
}

0 commit comments

Comments
 (0)