File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -19,12 +19,15 @@ import {
1919 kTextPlain ,
2020} from "../mime.ts" ;
2121import {
22+ JupyterCell ,
2223 JupyterOutput ,
2324 JupyterOutputDisplayData ,
2425 JupyterToMarkdownOptions ,
2526} from "./types.ts" ;
2627
27- export function isDisplayData ( output : JupyterOutput ) {
28+ export function isDisplayData (
29+ output : JupyterOutput ,
30+ ) : output is JupyterOutputDisplayData {
2831 return [ "display_data" , "execute_result" ] . includes ( output . output_type ) ;
2932}
3033
@@ -139,3 +142,21 @@ export function displayDataIsJson(mimeType: string) {
139142export function displayDataIsJavascript ( mimeType : string ) {
140143 return [ kApplicationJavascript ] . includes ( mimeType ) ;
141144}
145+
146+ export function cellHasOnlyMarkdownDisplayData (
147+ cell : JupyterCell ,
148+ options : JupyterToMarkdownOptions ,
149+ ) {
150+ if ( cell . outputs ) {
151+ return cell . outputs . every ( ( output ) => {
152+ if ( isDisplayData ( output ) ) {
153+ const mimeType = displayDataMimeType ( output , options ) ;
154+ return mimeType && displayDataIsMarkdown ( mimeType ) ;
155+ } else {
156+ return false ;
157+ }
158+ } ) ;
159+ } else {
160+ return false ;
161+ }
162+ }
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ import {
5151 shouldLabelOutputContainer ,
5252} from "./labels.ts" ;
5353import {
54+ cellHasOnlyMarkdownDisplayData ,
5455 displayDataIsHtml ,
5556 displayDataIsImage ,
5657 displayDataIsJavascript ,
@@ -926,7 +927,9 @@ async function mdFromCodeCell(
926927 cell . options [ kOutput ] === "asis" ||
927928 // specified globally with no output override for this cell
928929 ( options . execute [ kOutput ] === "asis" &&
929- cell . options [ kOutput ] === undefined ) ;
930+ cell . options [ kOutput ] === undefined ) ||
931+ // cell has only markdown display data
932+ cellHasOnlyMarkdownDisplayData ( cell , options ) ;
930933
931934 // markdown to return
932935 const md : string [ ] = [ ] ;
You can’t perform that action at this time.
0 commit comments