UNPKG

nbtx

Version:

Jupyter Notebook Translators: Transform Jupyter notebook JSON files (*.ipynb) to and from more compact data structures for use in web applications or other contexts where loading component parts (e.g. images, data, etc.) is preferred.

16 lines (15 loc) 504 B
import { KnownCellOutputMimeTypes } from './types.js'; export function extFromMimeType(mimeType) { if (mimeType === KnownCellOutputMimeTypes.TextHtml) return '.html'; if (mimeType === KnownCellOutputMimeTypes.TextLatex) return '.tex'; if (mimeType.startsWith('text/')) return '.txt'; if (mimeType.startsWith('image/')) { const suffix = mimeType.split('/')[1]; const ext = suffix.split('+')[0]; return `.${ext}`; } return '.json'; }