@jupyterlab/rendermime 0.15.4 → 0.16.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -204,26 +204,10 @@ export declare namespace renderSVG {
204
204
  * Whether the source is trusted.
205
205
  */
206
206
  trusted: boolean;
207
- /**
208
- * An optional url resolver.
209
- */
210
- resolver: IRenderMime.IResolver | null;
211
- /**
212
- * An optional link handler.
213
- */
214
- linkHandler: IRenderMime.ILinkHandler | null;
215
- /**
216
- * Whether the node should be typeset.
217
- */
218
- shouldTypeset: boolean;
219
207
  /**
220
208
  * Whether the svg should be unconfined.
221
209
  */
222
210
  unconfined?: boolean;
223
- /**
224
- * The LaTeX typesetter for the application.
225
- */
226
- latexTypesetter: IRenderMime.ILatexTypesetter | null;
227
211
  }
228
212
  }
229
213
  /**
package/lib/renderers.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  /*-----------------------------------------------------------------------------
4
3
  | Copyright (c) Jupyter Development Team.
5
4
  | Distributed under the terms of the Modified BSD License.
6
5
  |----------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  var ansi_up_1 = require("ansi_up");
8
8
  var marked = require("marked");
9
9
  var codemirror_1 = require("@jupyterlab/codemirror");
@@ -185,7 +185,7 @@ exports.renderMarkdown = renderMarkdown;
185
185
  */
186
186
  function renderSVG(options) {
187
187
  // Unpack the options.
188
- var host = options.host, source = options.source, trusted = options.trusted, resolver = options.resolver, linkHandler = options.linkHandler, shouldTypeset = options.shouldTypeset, latexTypesetter = options.latexTypesetter, unconfined = options.unconfined;
188
+ var host = options.host, source = options.source, trusted = options.trusted, unconfined = options.unconfined;
189
189
  // Clear the content if there is no source.
190
190
  if (!source) {
191
191
  host.textContent = '';
@@ -196,27 +196,14 @@ function renderSVG(options) {
196
196
  host.textContent = 'Cannot display an untrusted SVG. Maybe you need to run the cell?';
197
197
  return Promise.resolve(undefined);
198
198
  }
199
- // Set the inner HTML of the host.
200
- host.innerHTML = source;
199
+ // Render in img so that user can save it easily
200
+ var img = new Image();
201
+ img.src = "data:image/svg+xml," + source;
202
+ host.appendChild(img);
201
203
  if (unconfined === true) {
202
204
  host.classList.add('jp-mod-unconfined');
203
205
  }
204
- // TODO
205
- // what about script tags inside the svg?
206
- // Patch the urls if a resolver is available.
207
- var promise;
208
- if (resolver) {
209
- promise = Private.handleUrls(host, resolver, linkHandler);
210
- }
211
- else {
212
- promise = Promise.resolve(undefined);
213
- }
214
- // Return the final rendered promise.
215
- return promise.then(function () {
216
- if (shouldTypeset && latexTypesetter) {
217
- latexTypesetter.typeset(host);
218
- }
219
- });
206
+ return Promise.resolve();
220
207
  }
221
208
  exports.renderSVG = renderSVG;
222
209
  /**
@@ -229,10 +216,11 @@ exports.renderSVG = renderSVG;
229
216
  function renderText(options) {
230
217
  // Unpack the options.
231
218
  var host = options.host, source = options.source;
232
- // Escape the terminal codes and HTML tags.
233
- var data = ansi_up_1.escape_for_html(source);
219
+ var ansiUp = new ansi_up_1.default();
220
+ ansiUp.escape_for_html = true;
221
+ ansiUp.use_classes = true;
234
222
  // Create the HTML content.
235
- var content = ansi_up_1.ansi_to_html(data, { use_classes: true });
223
+ var content = ansiUp.ansi_to_html(source);
236
224
  // Set the inner HTML for the host node.
237
225
  host.innerHTML = "<pre>" + content + "</pre>";
238
226
  // Return the rendered promise.
@@ -389,6 +377,9 @@ var Private;
389
377
  return resolver.resolveUrl(source).then(function (path) {
390
378
  return resolver.getDownloadUrl(path);
391
379
  }).then(function (url) {
380
+ // Bust caching for local src attrs.
381
+ // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Bypassing_the_cache
382
+ url += ((/\?/).test(url) ? '&' : '?') + (new Date()).getTime();
392
383
  node.setAttribute(name, url);
393
384
  }).catch(function (err) {
394
385
  // If there was an error getting the url,
@@ -1 +1 @@
1
- {"version":3,"file":"ren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I,EAAE,IAAI,CAAC,CAAC;gBACxB,CAAC;gBACD,iBAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAA,IAAI;oBACzB,IAAI,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;oBACvC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;wBACV,OAAO,CAAC,GAAG,CAAC,yBAAuB,IAAM,CAAC,CAAC;wBAC3C,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;oBACxB,CAAC;oBACD,IAAI,CAAC;wBACH,iBAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;wBAC9B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC;oBAChC,CAAC;oBAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;wBACb,OAAO,CAAC,GAAG,CAAC,yBAAuB,IAAI,UAAO,EAAE,GAAG,CAAC,CAAC;wBACrD,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;oBACvB,CAAC;gBACH,CAAC,CAAC,CAAC,KAAK,CAAC,UAAA,GAAG;oBACV,OAAO,CAAC,GAAG,CAAC,yBAAuB,IAAM,CAAC,CAAC;oBAC3C,OAAO,CAAC,GAAG,CAAC,oCAAkC,GAAK,CAAC,CAAC;oBACrD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACxB,CAAC,CAAC,CAAC;gBACH,MAAM,CAAC,IAAI,CAAC;YACd,CAAC;SACF,CAAC,CAAC;IACL,CAAC;AACH,CAAC,EA/PS,OAAO,KAAP,OAAO,QA+PhB","sourcesContent":["/*-----------------------------------------------------------------------------\n| Copyright (c) Jupyter Development Team.\n| Distributed under the terms of the Modified BSD License.\n|----------------------------------------------------------------------------*/\nimport {\n ansi_to_html, escape_for_html\n} from 'ansi_up';\n\nimport * as marked\n from 'marked';\n\nimport {\n ISanitizer\n} from '@jupyterlab/apputils';\n\nimport {\n Mode, CodeMirrorEditor\n} from '@jupyterlab/codemirror';\n\nimport {\n URLExt\n} from '@jupyterlab/coreutils';\n\nimport {\n IRenderMime\n} from '@jupyterlab/rendermime-interfaces';\n\nimport {\n removeMath, replaceMath\n} from './latex';\n\n\n/**\n * Render HTML into a host node.\n *\n * @params options - The options for rendering.\n *\n * @returns A promise which resolves when rendering is complete.\n */\nexport\nfunction renderHTML(options: renderHTML.IOptions): Promise<void> {\n // Unpack the options.\n let {\n host, source, trusted, sanitizer, resolver, linkHandler,\n shouldTypeset, latexTypesetter\n } = options;\n\n // Bail early if the source is empty.\n if (!source) {\n host.textContent = '';\n return Promise.resolve(undefined);\n }\n\n // Sanitize the source if it is not trusted. This removes all\n // `<script>` tags as well as other potentially harmful HTML.\n if (!trusted) {\n source = sanitizer.sanitize(source);\n }\n\n // Set the inner HTML of the host.\n host.innerHTML = source;\n\n if (host.getElementsByTagName('script').length > 0) {\n console.warn('JupyterLab does not execute inline JavaScript in HTML output');\n }\n\n // TODO - arbitrary script execution is disabled for now.\n // Eval any script tags contained in the HTML. This is not done\n // automatically by the browser when script tags are created by\n // setting `innerHTML`. The santizer should have removed all of\n // the script tags for untrusted source, but this extra trusted\n // check is just extra insurance.\n // if (trusted) {\n // // TODO do we really want to run scripts? Because if so, there\n // // is really no difference between this and a JS mime renderer.\n // Private.evalInnerHTMLScriptTags(host);\n // }\n\n // Handle default behavior of nodes.\n Private.handleDefaults(host);\n\n // Patch the urls if a resolver is available.\n let promise: Promise<void>;\n if (resolver) {\n promise = Private.handleUrls(host, resolver, linkHandler);\n } else {\n promise = Promise.resolve(undefined);\n }\n\n // Return the final rendered promise.\n return promise.then(() => {\n if (shouldTypeset && latexTypesetter ) { latexTypesetter.typeset(host); }\n });\n}\n\n\n/**\n * The namespace for the `renderHTML` function statics.\n */\nexport\nnamespace renderHTML {\n /**\n * The options for the `renderHTML` function.\n */\n export\n interface IOptions {\n /**\n * The host node for the rendered HTML.\n */\n host: HTMLElement;\n\n /**\n * The HTML source to render.\n */\n source: string;\n\n /**\n * Whether the source is trusted.\n */\n trusted: boolean;\n\n /**\n * The html sanitizer for untrusted source.\n */\n sanitizer: ISanitizer;\n\n /**\n * An optional url resolver.\n */\n resolver: IRenderMime.IResolver | null;\n\n /**\n * An optional link handler.\n */\n linkHandler: IRenderMime.ILinkHandler | null;\n\n /**\n * Whether the node should be typeset.\n */\n shouldTypeset: boolean;\n\n /**\n * The LaTeX typesetter for the application.\n */\n latexTypesetter: IRenderMime.ILatexTypesetter | null;\n }\n}\n\n\n/**\n * Render an image into a host node.\n *\n * @params options - The options for rendering.\n *\n * @returns A promise which resolves when rendering is complete.\n */\nexport\nfunction renderImage(options: renderImage.IRenderOptions): Promise<void> {\n // Unpack the options.\n let { host, mimeType, source, width, height, unconfined } = options;\n\n // Clear the content in the host.\n host.textContent = '';\n\n // Create the image element.\n let img = document.createElement('img');\n\n // Set the source of the image.\n img.src = `data:${mimeType};base64,${source}`;\n\n // Set the size of the image if provided.\n if (typeof height === 'number') {\n img.height = height;\n }\n if (typeof width === 'number') {\n img.width = width;\n }\n\n if (unconfined === true) {\n img.classList.add('jp-mod-unconfined');\n }\n\n // Add the image to the host.\n host.appendChild(img);\n\n // Return the rendered promise.\n return Promise.resolve(undefined);\n}\n\n\n/**\n * The namespace for the `renderImage` function statics.\n */\nexport\nnamespace renderImage {\n /**\n * The options for the `renderImage` function.\n */\n export\n interface IRenderOptions {\n /**\n * The image node to update with the content.\n */\n host: HTMLElement;\n\n /**\n * The mime type for the image.\n */\n mimeType: string;\n\n /**\n * The base64 encoded source for the image.\n */\n source: string;\n\n /**\n * The optional width for the image.\n */\n width?: number;\n\n /**\n * The optional height for the image.\n */\n height?: number;\n\n /**\n * Whether the image should be unconfined.\n */\n unconfined?: boolean;\n }\n}\n\n\n/**\n * Render LaTeX into a host node.\n *\n * @params options - The options for rendering.\n *\n * @returns A promise which resolves when rendering is complete.\n */\nexport\nfunction renderLatex(options: renderLatex.IRenderOptions): Promise<void> {\n // Unpack the options.\n let { host, source, shouldTypeset, latexTypesetter } = options;\n\n // Set the source on the node.\n host.textContent = source;\n\n // Typeset the node if needed.\n if (shouldTypeset && latexTypesetter) {\n latexTypesetter.typeset(host);\n }\n\n // Return the rendered promise.\n return Promise.resolve(undefined);\n}\n\n\n/**\n * The namespace for the `renderLatex` function statics.\n */\nexport\nnamespace renderLatex {\n /**\n * The options for the `renderLatex` function.\n */\n export\n interface IRenderOptions {\n /**\n * The host node for the rendered LaTeX.\n */\n host: HTMLElement;\n\n /**\n * The LaTeX source to render.\n */\n source: string;\n\n /**\n * Whether the node should be typeset.\n */\n shouldTypeset: boolean;\n\n /**\n * The LaTeX typesetter for the application.\n */\n latexTypesetter: IRenderMime.ILatexTypesetter | null;\n }\n}\n\n\n/**\n * Render Markdown into a host node.\n *\n * @params options - The options for rendering.\n *\n * @returns A promise which resolves when rendering is complete.\n */\nexport\nfunction renderMarkdown(options: renderMarkdown.IRenderOptions): Promise<void> {\n // Unpack the options.\n let {\n host, source, trusted, sanitizer, resolver, linkHandler,\n latexTypesetter, shouldTypeset\n } = options;\n\n // Clear the content if there is no source.\n if (!source) {\n host.textContent = '';\n return Promise.resolve(undefined);\n }\n\n // Separate math from normal markdown text.\n let parts = removeMath(source);\n\n // Render the markdown and handle sanitization.\n return Private.renderMarked(parts['text']).then(content => {\n // Restore the math content in the rendered markdown.\n content = replaceMath(content, parts['math']);\n\n // Santize the content it is not trusted.\n if (!trusted) {\n content = sanitizer.sanitize(content);\n }\n\n // Set the inner HTML of the host.\n host.innerHTML = content;\n\n if (host.getElementsByTagName('script').length > 0) {\n console.warn('JupyterLab does not execute inline JavaScript in HTML output');\n }\n\n // TODO arbitrary script execution is disabled for now.\n // Eval any script tags contained in the HTML. This is not done\n // automatically by the browser when script tags are created by\n // setting `innerHTML`. The santizer should have removed all of\n // the script tags for untrusted source, but this extra trusted\n // check is just extra insurance.\n // if (trusted) {\n // // TODO really want to run scripts?\n // Private.evalInnerHTMLScriptTags(host);\n // }\n\n // Handle default behavior of nodes.\n Private.handleDefaults(host);\n\n // Apply ids to the header nodes.\n Private.headerAnchors(host);\n\n // Patch the urls if a resolver is available.\n let promise: Promise<void>;\n if (resolver) {\n promise = Private.handleUrls(host, resolver, linkHandler);\n } else {\n promise = Promise.resolve(undefined);\n }\n\n // Return the rendered promise.\n return promise;\n }).then(() => {\n if (shouldTypeset && latexTypesetter) {\n latexTypesetter.typeset(host);\n }\n });\n}\n\n\n/**\n * The namespace for the `renderMarkdown` function statics.\n */\nexport\nnamespace renderMarkdown {\n /**\n * The options for the `renderMarkdown` function.\n */\n export\n interface IRenderOptions {\n /**\n * The host node for the rendered Markdown.\n */\n host: HTMLElement;\n\n /**\n * The Markdown source to render.\n */\n source: string;\n\n /**\n * Whether the source is trusted.\n */\n trusted: boolean;\n\n /**\n * The html sanitizer for untrusted source.\n */\n sanitizer: ISanitizer;\n\n /**\n * An optional url resolver.\n */\n resolver: IRenderMime.IResolver | null;\n\n /**\n * An optional link handler.\n */\n linkHandler: IRenderMime.ILinkHandler | null;\n\n /**\n * Whether the node should be typeset.\n */\n shouldTypeset: boolean;\n\n /**\n * The LaTeX typesetter for the application.\n */\n latexTypesetter: IRenderMime.ILatexTypesetter | null;\n }\n}\n\n/**\n * Render SVG into a host node.\n *\n * @params options - The options for rendering.\n *\n * @returns A promise which resolves when rendering is complete.\n */\nexport\nfunction renderSVG(options: renderSVG.IRenderOptions): Promise<void> {\n // Unpack the options.\n let {\n host, source, trusted, resolver, linkHandler,\n shouldTypeset, latexTypesetter, unconfined\n } = options;\n\n // Clear the content if there is no source.\n if (!source) {\n host.textContent = '';\n return Promise.resolve(undefined);\n }\n\n // Display a message if the source is not trusted.\n if (!trusted) {\n host.textContent = 'Cannot display an untrusted SVG. Maybe you need to run the cell?';\n return Promise.resolve(undefined);\n }\n\n // Set the inner HTML of the host.\n host.innerHTML = source;\n\n if (unconfined === true) {\n host.classList.add('jp-mod-unconfined');\n }\n\n // TODO\n // what about script tags inside the svg?\n\n // Patch the urls if a resolver is available.\n let promise: Promise<void>;\n if (resolver) {\n promise = Private.handleUrls(host, resolver, linkHandler);\n } else {\n promise = Promise.resolve(undefined);\n }\n\n // Return the final rendered promise.\n return promise.then(() => {\n if (shouldTypeset && latexTypesetter) { latexTypesetter.typeset(host); }\n });\n}\n\n\n/**\n * The namespace for the `renderSVG` function statics.\n */\nexport\nnamespace renderSVG {\n /**\n * The options for the `renderSVG` function.\n */\n export\n interface IRenderOptions {\n /**\n * The host node for the rendered SVG.\n */\n host: HTMLElement;\n\n /**\n * The SVG source.\n */\n source: string;\n\n /**\n * Whether the source is trusted.\n */\n trusted: boolean;\n\n /**\n * An optional url resolver.\n */\n resolver: IRenderMime.IResolver | null;\n\n /**\n * An optional link handler.\n */\n linkHandler: IRenderMime.ILinkHandler | null;\n\n /**\n * Whether the node should be typeset.\n */\n shouldTypeset: boolean;\n\n /**\n * Whether the svg should be unconfined.\n */\n unconfined?: boolean;\n\n /**\n * The LaTeX typesetter for the application.\n */\n latexTypesetter: IRenderMime.ILatexTypesetter | null;\n }\n}\n\n\n/**\n * Render text into a host node.\n *\n * @params options - The options for rendering.\n *\n * @returns A promise which resolves when rendering is complete.\n */\nexport\nfunction renderText(options: renderText.IRenderOptions): Promise<void> {\n // Unpack the options.\n let { host, source } = options;\n\n // Escape the terminal codes and HTML tags.\n let data = escape_for_html(source);\n\n // Create the HTML content.\n let content = ansi_to_html(data, { use_classes: true });\n\n // Set the inner HTML for the host node.\n host.innerHTML = `<pre>${content}</pre>`;\n\n // Return the rendered promise.\n return Promise.resolve(undefined);\n}\n\n\n/**\n * The namespace for the `renderText` function statics.\n */\nexport\nnamespace renderText {\n /**\n * The options for the `renderText` function.\n */\n export\n interface IRenderOptions {\n /**\n * The host node for the text content.\n */\n host: HTMLElement;\n\n /**\n * The source text to render.\n */\n source: string;\n }\n}\n\n\n/**\n * The namespace for module implementation details.\n */\nnamespace Private {\n // This is disabled for now until we decide we actually really\n // truly want to allow arbitrary script execution.\n /**\n * Eval the script tags contained in a host populated by `innerHTML`.\n *\n * When script tags are created via `innerHTML`, the browser does not\n * evaluate them when they are added to the page. This function works\n * around that by creating new equivalent script nodes manually, and\n * replacing the originals.\n */\n // export\n // function evalInnerHTMLScriptTags(host: HTMLElement): void {\n // // Create a snapshot of the current script nodes.\n // let scripts = toArray(host.getElementsByTagName('script'));\n\n // // Loop over each script node.\n // for (let script of scripts) {\n // // Skip any scripts which no longer have a parent.\n // if (!script.parentNode) {\n // continue;\n // }\n\n // // Create a new script node which will be clone.\n // let clone = document.createElement('script');\n\n // // Copy the attributes into the clone.\n // let attrs = script.attributes;\n // for (let i = 0, n = attrs.length; i < n; ++i) {\n // let { name, value } = attrs[i];\n // clone.setAttribute(name, value);\n // }\n\n // // Copy the text content into the clone.\n // clone.textContent = script.textContent;\n\n // // Replace the old script in the parent.\n // script.parentNode.replaceChild(clone, script);\n // }\n // }\n\n /**\n * Render markdown for the specified content.\n *\n * @param content - The string of markdown to render.\n *\n * @return A promise which resolves with the rendered content.\n */\n export\n function renderMarked(content: string): Promise<string> {\n initializeMarked();\n return new Promise<string>((resolve, reject) => {\n marked(content, (err: any, content: string) => {\n if (err) {\n reject(err);\n } else {\n resolve(content);\n }\n });\n });\n }\n\n /**\n * Handle the default behavior of nodes.\n */\n export\n function handleDefaults(node: HTMLElement): void {\n // Handle anchor elements.\n let anchors = node.getElementsByTagName('a');\n for (let i = 0; i < anchors.length; i++) {\n let path = anchors[i].href;\n if (URLExt.isLocal(path)) {\n anchors[i].target = '_self';\n } else {\n anchors[i].target = '_blank';\n }\n }\n\n // Handle image elements.\n let imgs = node.getElementsByTagName('img');\n for (let i = 0; i < imgs.length; i++) {\n if (!imgs[i].alt) {\n imgs[i].alt = 'Image';\n }\n }\n }\n\n /**\n * Resolve the relative urls in element `src` and `href` attributes.\n *\n * @param node - The head html element.\n *\n * @param resolver - A url resolver.\n *\n * @param linkHandler - An optional link handler for nodes.\n *\n * @returns a promise fulfilled when the relative urls have been resolved.\n */\n export\n function handleUrls(node: HTMLElement, resolver: IRenderMime.IResolver, linkHandler: IRenderMime.ILinkHandler | null): Promise<void> {\n // Set up an array to collect promises.\n let promises: Promise<void>[] = [];\n\n // Handle HTML Elements with src attributes.\n let nodes = node.querySelectorAll('*[src]');\n for (let i = 0; i < nodes.length; i++) {\n promises.push(handleAttr(nodes[i] as HTMLElement, 'src', resolver));\n }\n\n // Handle anchor elements.\n let anchors = node.getElementsByTagName('a');\n for (let i = 0; i < anchors.length; i++) {\n promises.push(handleAnchor(anchors[i], resolver, linkHandler));\n }\n\n // Handle link elements.\n let links = node.getElementsByTagName('link');\n for (let i = 0; i < links.length; i++) {\n promises.push(handleAttr(links[i], 'href', resolver));\n }\n\n // Wait on all promises.\n return Promise.all(promises).then(() => undefined);\n }\n\n /**\n * Apply ids to headers.\n */\n export\n function headerAnchors(node: HTMLElement): void {\n let headerNames = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];\n for (let headerType of headerNames) {\n let headers = node.getElementsByTagName(headerType);\n for (let i=0; i < headers.length; i++) {\n let header = headers[i];\n header.id = header.innerHTML.replace(/ /g, '-');\n let anchor = document.createElement('a');\n anchor.target = '_self';\n anchor.textContent = '¶';\n anchor.href = '#' + header.id;\n anchor.classList.add('jp-InternalAnchorLink');\n header.appendChild(anchor);\n }\n }\n }\n\n /**\n * Handle a node with a `src` or `href` attribute.\n */\n function handleAttr(node: HTMLElement, name: 'src' | 'href', resolver: IRenderMime.IResolver): Promise<void> {\n let source = node.getAttribute(name);\n if (!source || URLExt.parse(source).protocol === 'data:') {\n return Promise.resolve(undefined);\n }\n node.setAttribute(name, '');\n return resolver.resolveUrl(source).then(path => {\n return resolver.getDownloadUrl(path);\n }).then(url => {\n node.setAttribute(name, url);\n }).catch(err => {\n // If there was an error getting the url,\n // just make it an empty link.\n node.setAttribute(name, '');\n });\n }\n\n /**\n * Handle an anchor node.\n */\n function handleAnchor(anchor: HTMLAnchorElement, resolver: IRenderMime.IResolver, linkHandler: IRenderMime.ILinkHandler | null): Promise<void> {\n // Get the link path without the location prepended.\n // (e.g. \"./foo.md#Header 1\" vs \"http://localhost:8888/foo.md#Header 1\")\n let href = anchor.getAttribute('href');\n // Bail if it is not a file-like url.\n if (!href || href.indexOf('://') !== -1 && href.indexOf('//') === 0) {\n return Promise.resolve(undefined);\n }\n // Remove the hash until we can handle it.\n let hash = anchor.hash;\n if (hash) {\n // Handle internal link in the file.\n if (hash === href) {\n anchor.target = '_self';\n return Promise.resolve(undefined);\n }\n // For external links, remove the hash until we have hash handling.\n href = href.replace(hash, '');\n }\n // Get the appropriate file path.\n return resolver.resolveUrl(href).then(path => {\n // Handle the click override.\n if (linkHandler && URLExt.isLocal(path)) {\n linkHandler.handleLink(anchor, path);\n }\n // Get the appropriate file download path.\n return resolver.getDownloadUrl(path);\n }).then(url => {\n // Set the visible anchor.\n anchor.href = url + hash;\n }).catch(err => {\n // If there was an error getting the url,\n // just make it an empty link.\n anchor.href = '';\n });\n }\n\n let markedInitialized = false;\n\n /**\n * Support GitHub flavored Markdown, leave sanitizing to external library.\n */\n function initializeMarked(): void {\n if (markedInitialized) {\n return;\n }\n markedInitialized = true;\n marked.setOptions({\n gfm: true,\n sanitize: false,\n tables: true,\n // breaks: true; We can't use GFM breaks as it causes problems with tables\n langPrefix: `cm-s-${CodeMirrorEditor.defaultConfig.theme} language-`,\n highlight: (code, lang, callback) => {\n let cb = (err: Error | null, code: string) => {\n if (callback) {\n callback(err, code);\n }\n return code;\n };\n if (!lang) {\n // no language, no highlight\n return cb(null, code);\n }\n Mode.ensure(lang).then(spec => {\n let el = document.createElement('div');\n if (!spec) {\n console.log(`No CodeMirror mode: ${lang}`);\n return cb(null, code);\n }\n try {\n Mode.run(code, spec.mime, el);\n return cb(null, el.innerHTML);\n } catch (err) {\n console.log(`Failed to highlight ${lang} code`, err);\n return cb(err, code);\n }\n }).catch(err => {\n console.log(`No CodeMirror mode: ${lang}`);\n console.log(`Require CodeMirror mode error: ${err}`);\n return cb(null, code);\n });\n return code;\n }\n });\n }\n}\n"]}
1
+ {"version":3,"file":"renderers.js","sourceRoot":"","sources":["../../../../rendermime/src/renderers.ts"],"names":[],"mappings":";AAAA;;;+EAG+E;;AAE/E,mCAEiB;AAEjB,+BACgB;AAMhB,qDAEgC;AAEhC,mDAE+B;AAM/B,iCAEiB;AAGjB;;;;;;GAMG;AACH,oBACoB,OAA4B;IAC9C,sBAAsB;IAEpB,IAAA,mBAAI,EAAE,uBAAM,EAAE,yBAAO,EAAE,6BAAS,EAAE,2BAAQ,EAAE,iCAAW,EACvD,qCAAa,EAAE,yCAAe,CACpB;IAEZ,qCAAqC;IACrC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;QACZ,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;IAED,6DAA6D;IAC7D,6DAA6D;IAC7D,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QACb,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,kCAAkC;IAClC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC;IAExB,EAAE,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;QACnD,OAAO,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;IAC/E,CAAC;IAED,yDAAyD;IACzD,+DAA+D;IAC/D,+DAA+D;IAC/D,+DAA+D;IAC/D,+DAA+D;IAC/D,iCAAiC;IACjC,iBAAiB;IACjB,mEAAmE;IACnE,oEAAoE;IACpE,2CAA2C;IAC3C,IAAI;IAEJ,oCAAoC;IACp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AAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACxB,CAAC;gBACD,iBAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAA,IAAI;oBACzB,IAAI,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;oBACvC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;wBACV,OAAO,CAAC,GAAG,CAAC,yBAAuB,IAAM,CAAC,CAAC;wBAC3C,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;oBACxB,CAAC;oBACD,IAAI,CAAC;wBACH,iBAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;wBAC9B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC;oBAChC,CAAC;oBAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;wBACb,OAAO,CAAC,GAAG,CAAC,yBAAuB,IAAI,UAAO,EAAE,GAAG,CAAC,CAAC;wBACrD,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;oBACvB,CAAC;gBACH,CAAC,CAAC,CAAC,KAAK,CAAC,UAAA,GAAG;oBACV,OAAO,CAAC,GAAG,CAAC,yBAAuB,IAAM,CAAC,CAAC;oBAC3C,OAAO,CAAC,GAAG,CAAC,oCAAkC,GAAK,CAAC,CAAC;oBACrD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACxB,CAAC,CAAC,CAAC;gBACH,MAAM,CAAC,IAAI,CAAC;YACd,CAAC;SACF,CAAC,CAAC;IACL,CAAC;AACH,CAAC,EAlQS,OAAO,KAAP,OAAO,QAkQhB","sourcesContent":["/*-----------------------------------------------------------------------------\n| Copyright (c) Jupyter Development Team.\n| Distributed under the terms of the Modified BSD License.\n|----------------------------------------------------------------------------*/\n\nimport {\n default as AnsiUp\n} from 'ansi_up';\n\nimport * as marked\n from 'marked';\n\nimport {\n ISanitizer\n} from '@jupyterlab/apputils';\n\nimport {\n Mode, CodeMirrorEditor\n} from '@jupyterlab/codemirror';\n\nimport {\n URLExt\n} from '@jupyterlab/coreutils';\n\nimport {\n IRenderMime\n} from '@jupyterlab/rendermime-interfaces';\n\nimport {\n removeMath, replaceMath\n} from './latex';\n\n\n/**\n * Render HTML into a host node.\n *\n * @params options - The options for rendering.\n *\n * @returns A promise which resolves when rendering is complete.\n */\nexport\nfunction renderHTML(options: renderHTML.IOptions): Promise<void> {\n // Unpack the options.\n let {\n host, source, trusted, sanitizer, resolver, linkHandler,\n shouldTypeset, latexTypesetter\n } = options;\n\n // Bail early if the source is empty.\n if (!source) {\n host.textContent = '';\n return Promise.resolve(undefined);\n }\n\n // Sanitize the source if it is not trusted. This removes all\n // `<script>` tags as well as other potentially harmful HTML.\n if (!trusted) {\n source = sanitizer.sanitize(source);\n }\n\n // Set the inner HTML of the host.\n host.innerHTML = source;\n\n if (host.getElementsByTagName('script').length > 0) {\n console.warn('JupyterLab does not execute inline JavaScript in HTML output');\n }\n\n // TODO - arbitrary script execution is disabled for now.\n // Eval any script tags contained in the HTML. This is not done\n // automatically by the browser when script tags are created by\n // setting `innerHTML`. The santizer should have removed all of\n // the script tags for untrusted source, but this extra trusted\n // check is just extra insurance.\n // if (trusted) {\n // // TODO do we really want to run scripts? Because if so, there\n // // is really no difference between this and a JS mime renderer.\n // Private.evalInnerHTMLScriptTags(host);\n // }\n\n // Handle default behavior of nodes.\n Private.handleDefaults(host);\n\n // Patch the urls if a resolver is available.\n let promise: Promise<void>;\n if (resolver) {\n promise = Private.handleUrls(host, resolver, linkHandler);\n } else {\n promise = Promise.resolve(undefined);\n }\n\n // Return the final rendered promise.\n return promise.then(() => {\n if (shouldTypeset && latexTypesetter ) { latexTypesetter.typeset(host); }\n });\n}\n\n\n/**\n * The namespace for the `renderHTML` function statics.\n */\nexport\nnamespace renderHTML {\n /**\n * The options for the `renderHTML` function.\n */\n export\n interface IOptions {\n /**\n * The host node for the rendered HTML.\n */\n host: HTMLElement;\n\n /**\n * The HTML source to render.\n */\n source: string;\n\n /**\n * Whether the source is trusted.\n */\n trusted: boolean;\n\n /**\n * The html sanitizer for untrusted source.\n */\n sanitizer: ISanitizer;\n\n /**\n * An optional url resolver.\n */\n resolver: IRenderMime.IResolver | null;\n\n /**\n * An optional link handler.\n */\n linkHandler: IRenderMime.ILinkHandler | null;\n\n /**\n * Whether the node should be typeset.\n */\n shouldTypeset: boolean;\n\n /**\n * The LaTeX typesetter for the application.\n */\n latexTypesetter: IRenderMime.ILatexTypesetter | null;\n }\n}\n\n\n/**\n * Render an image into a host node.\n *\n * @params options - The options for rendering.\n *\n * @returns A promise which resolves when rendering is complete.\n */\nexport\nfunction renderImage(options: renderImage.IRenderOptions): Promise<void> {\n // Unpack the options.\n let { host, mimeType, source, width, height, unconfined } = options;\n\n // Clear the content in the host.\n host.textContent = '';\n\n // Create the image element.\n let img = document.createElement('img');\n\n // Set the source of the image.\n img.src = `data:${mimeType};base64,${source}`;\n\n // Set the size of the image if provided.\n if (typeof height === 'number') {\n img.height = height;\n }\n if (typeof width === 'number') {\n img.width = width;\n }\n\n if (unconfined === true) {\n img.classList.add('jp-mod-unconfined');\n }\n\n // Add the image to the host.\n host.appendChild(img);\n\n // Return the rendered promise.\n return Promise.resolve(undefined);\n}\n\n\n/**\n * The namespace for the `renderImage` function statics.\n */\nexport\nnamespace renderImage {\n /**\n * The options for the `renderImage` function.\n */\n export\n interface IRenderOptions {\n /**\n * The image node to update with the content.\n */\n host: HTMLElement;\n\n /**\n * The mime type for the image.\n */\n mimeType: string;\n\n /**\n * The base64 encoded source for the image.\n */\n source: string;\n\n /**\n * The optional width for the image.\n */\n width?: number;\n\n /**\n * The optional height for the image.\n */\n height?: number;\n\n /**\n * Whether the image should be unconfined.\n */\n unconfined?: boolean;\n }\n}\n\n\n/**\n * Render LaTeX into a host node.\n *\n * @params options - The options for rendering.\n *\n * @returns A promise which resolves when rendering is complete.\n */\nexport\nfunction renderLatex(options: renderLatex.IRenderOptions): Promise<void> {\n // Unpack the options.\n let { host, source, shouldTypeset, latexTypesetter } = options;\n\n // Set the source on the node.\n host.textContent = source;\n\n // Typeset the node if needed.\n if (shouldTypeset && latexTypesetter) {\n latexTypesetter.typeset(host);\n }\n\n // Return the rendered promise.\n return Promise.resolve(undefined);\n}\n\n\n/**\n * The namespace for the `renderLatex` function statics.\n */\nexport\nnamespace renderLatex {\n /**\n * The options for the `renderLatex` function.\n */\n export\n interface IRenderOptions {\n /**\n * The host node for the rendered LaTeX.\n */\n host: HTMLElement;\n\n /**\n * The LaTeX source to render.\n */\n source: string;\n\n /**\n * Whether the node should be typeset.\n */\n shouldTypeset: boolean;\n\n /**\n * The LaTeX typesetter for the application.\n */\n latexTypesetter: IRenderMime.ILatexTypesetter | null;\n }\n}\n\n\n/**\n * Render Markdown into a host node.\n *\n * @params options - The options for rendering.\n *\n * @returns A promise which resolves when rendering is complete.\n */\nexport\nfunction renderMarkdown(options: renderMarkdown.IRenderOptions): Promise<void> {\n // Unpack the options.\n let {\n host, source, trusted, sanitizer, resolver, linkHandler,\n latexTypesetter, shouldTypeset\n } = options;\n\n // Clear the content if there is no source.\n if (!source) {\n host.textContent = '';\n return Promise.resolve(undefined);\n }\n\n // Separate math from normal markdown text.\n let parts = removeMath(source);\n\n // Render the markdown and handle sanitization.\n return Private.renderMarked(parts['text']).then(content => {\n // Restore the math content in the rendered markdown.\n content = replaceMath(content, parts['math']);\n\n // Santize the content it is not trusted.\n if (!trusted) {\n content = sanitizer.sanitize(content);\n }\n\n // Set the inner HTML of the host.\n host.innerHTML = content;\n\n if (host.getElementsByTagName('script').length > 0) {\n console.warn('JupyterLab does not execute inline JavaScript in HTML output');\n }\n\n // TODO arbitrary script execution is disabled for now.\n // Eval any script tags contained in the HTML. This is not done\n // automatically by the browser when script tags are created by\n // setting `innerHTML`. The santizer should have removed all of\n // the script tags for untrusted source, but this extra trusted\n // check is just extra insurance.\n // if (trusted) {\n // // TODO really want to run scripts?\n // Private.evalInnerHTMLScriptTags(host);\n // }\n\n // Handle default behavior of nodes.\n Private.handleDefaults(host);\n\n // Apply ids to the header nodes.\n Private.headerAnchors(host);\n\n // Patch the urls if a resolver is available.\n let promise: Promise<void>;\n if (resolver) {\n promise = Private.handleUrls(host, resolver, linkHandler);\n } else {\n promise = Promise.resolve(undefined);\n }\n\n // Return the rendered promise.\n return promise;\n }).then(() => {\n if (shouldTypeset && latexTypesetter) {\n latexTypesetter.typeset(host);\n }\n });\n}\n\n\n/**\n * The namespace for the `renderMarkdown` function statics.\n */\nexport\nnamespace renderMarkdown {\n /**\n * The options for the `renderMarkdown` function.\n */\n export\n interface IRenderOptions {\n /**\n * The host node for the rendered Markdown.\n */\n host: HTMLElement;\n\n /**\n * The Markdown source to render.\n */\n source: string;\n\n /**\n * Whether the source is trusted.\n */\n trusted: boolean;\n\n /**\n * The html sanitizer for untrusted source.\n */\n sanitizer: ISanitizer;\n\n /**\n * An optional url resolver.\n */\n resolver: IRenderMime.IResolver | null;\n\n /**\n * An optional link handler.\n */\n linkHandler: IRenderMime.ILinkHandler | null;\n\n /**\n * Whether the node should be typeset.\n */\n shouldTypeset: boolean;\n\n /**\n * The LaTeX typesetter for the application.\n */\n latexTypesetter: IRenderMime.ILatexTypesetter | null;\n }\n}\n\n/**\n * Render SVG into a host node.\n *\n * @params options - The options for rendering.\n *\n * @returns A promise which resolves when rendering is complete.\n */\nexport\nfunction renderSVG(options: renderSVG.IRenderOptions): Promise<void> {\n // Unpack the options.\n let {\n host, source, trusted, unconfined\n } = options;\n\n // Clear the content if there is no source.\n if (!source) {\n host.textContent = '';\n return Promise.resolve(undefined);\n }\n\n // Display a message if the source is not trusted.\n if (!trusted) {\n host.textContent = 'Cannot display an untrusted SVG. Maybe you need to run the cell?';\n return Promise.resolve(undefined);\n }\n\n // Render in img so that user can save it easily\n const img = new Image();\n img.src = `data:image/svg+xml,${source}`;\n host.appendChild(img);\n\n if (unconfined === true) {\n host.classList.add('jp-mod-unconfined');\n }\n return Promise.resolve();\n}\n\n\n/**\n * The namespace for the `renderSVG` function statics.\n */\nexport\nnamespace renderSVG {\n /**\n * The options for the `renderSVG` function.\n */\n export\n interface IRenderOptions {\n /**\n * The host node for the rendered SVG.\n */\n host: HTMLElement;\n\n /**\n * The SVG source.\n */\n source: string;\n\n /**\n * Whether the source is trusted.\n */\n trusted: boolean;\n\n /**\n * Whether the svg should be unconfined.\n */\n unconfined?: boolean;\n }\n}\n\n\n/**\n * Render text into a host node.\n *\n * @params options - The options for rendering.\n *\n * @returns A promise which resolves when rendering is complete.\n */\nexport\nfunction renderText(options: renderText.IRenderOptions): Promise<void> {\n // Unpack the options.\n let { host, source } = options;\n\n const ansiUp = new AnsiUp();\n ansiUp.escape_for_html = true;\n ansiUp.use_classes = true;\n\n // Create the HTML content.\n let content = ansiUp.ansi_to_html(source);\n\n // Set the inner HTML for the host node.\n host.innerHTML = `<pre>${content}</pre>`;\n\n // Return the rendered promise.\n return Promise.resolve(undefined);\n}\n\n\n/**\n * The namespace for the `renderText` function statics.\n */\nexport\nnamespace renderText {\n /**\n * The options for the `renderText` function.\n */\n export\n interface IRenderOptions {\n /**\n * The host node for the text content.\n */\n host: HTMLElement;\n\n /**\n * The source text to render.\n */\n source: string;\n }\n}\n\n\n/**\n * The namespace for module implementation details.\n */\nnamespace Private {\n // This is disabled for now until we decide we actually really\n // truly want to allow arbitrary script execution.\n /**\n * Eval the script tags contained in a host populated by `innerHTML`.\n *\n * When script tags are created via `innerHTML`, the browser does not\n * evaluate them when they are added to the page. This function works\n * around that by creating new equivalent script nodes manually, and\n * replacing the originals.\n */\n // export\n // function evalInnerHTMLScriptTags(host: HTMLElement): void {\n // // Create a snapshot of the current script nodes.\n // let scripts = toArray(host.getElementsByTagName('script'));\n\n // // Loop over each script node.\n // for (let script of scripts) {\n // // Skip any scripts which no longer have a parent.\n // if (!script.parentNode) {\n // continue;\n // }\n\n // // Create a new script node which will be clone.\n // let clone = document.createElement('script');\n\n // // Copy the attributes into the clone.\n // let attrs = script.attributes;\n // for (let i = 0, n = attrs.length; i < n; ++i) {\n // let { name, value } = attrs[i];\n // clone.setAttribute(name, value);\n // }\n\n // // Copy the text content into the clone.\n // clone.textContent = script.textContent;\n\n // // Replace the old script in the parent.\n // script.parentNode.replaceChild(clone, script);\n // }\n // }\n\n /**\n * Render markdown for the specified content.\n *\n * @param content - The string of markdown to render.\n *\n * @return A promise which resolves with the rendered content.\n */\n export\n function renderMarked(content: string): Promise<string> {\n initializeMarked();\n return new Promise<string>((resolve, reject) => {\n marked(content, (err: any, content: string) => {\n if (err) {\n reject(err);\n } else {\n resolve(content);\n }\n });\n });\n }\n\n /**\n * Handle the default behavior of nodes.\n */\n export\n function handleDefaults(node: HTMLElement): void {\n // Handle anchor elements.\n let anchors = node.getElementsByTagName('a');\n for (let i = 0; i < anchors.length; i++) {\n let path = anchors[i].href;\n if (URLExt.isLocal(path)) {\n anchors[i].target = '_self';\n } else {\n anchors[i].target = '_blank';\n }\n }\n\n // Handle image elements.\n let imgs = node.getElementsByTagName('img');\n for (let i = 0; i < imgs.length; i++) {\n if (!imgs[i].alt) {\n imgs[i].alt = 'Image';\n }\n }\n }\n\n /**\n * Resolve the relative urls in element `src` and `href` attributes.\n *\n * @param node - The head html element.\n *\n * @param resolver - A url resolver.\n *\n * @param linkHandler - An optional link handler for nodes.\n *\n * @returns a promise fulfilled when the relative urls have been resolved.\n */\n export\n function handleUrls(node: HTMLElement, resolver: IRenderMime.IResolver, linkHandler: IRenderMime.ILinkHandler | null): Promise<void> {\n // Set up an array to collect promises.\n let promises: Promise<void>[] = [];\n\n // Handle HTML Elements with src attributes.\n let nodes = node.querySelectorAll('*[src]');\n for (let i = 0; i < nodes.length; i++) {\n promises.push(handleAttr(nodes[i] as HTMLElement, 'src', resolver));\n }\n\n // Handle anchor elements.\n let anchors = node.getElementsByTagName('a');\n for (let i = 0; i < anchors.length; i++) {\n promises.push(handleAnchor(anchors[i], resolver, linkHandler));\n }\n\n // Handle link elements.\n let links = node.getElementsByTagName('link');\n for (let i = 0; i < links.length; i++) {\n promises.push(handleAttr(links[i], 'href', resolver));\n }\n\n // Wait on all promises.\n return Promise.all(promises).then(() => undefined);\n }\n\n /**\n * Apply ids to headers.\n */\n export\n function headerAnchors(node: HTMLElement): void {\n let headerNames = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];\n for (let headerType of headerNames) {\n let headers = node.getElementsByTagName(headerType);\n for (let i=0; i < headers.length; i++) {\n let header = headers[i];\n header.id = header.innerHTML.replace(/ /g, '-');\n let anchor = document.createElement('a');\n anchor.target = '_self';\n anchor.textContent = '¶';\n anchor.href = '#' + header.id;\n anchor.classList.add('jp-InternalAnchorLink');\n header.appendChild(anchor);\n }\n }\n }\n\n /**\n * Handle a node with a `src` or `href` attribute.\n */\n function handleAttr(node: HTMLElement, name: 'src' | 'href', resolver: IRenderMime.IResolver): Promise<void> {\n let source = node.getAttribute(name);\n if (!source || URLExt.parse(source).protocol === 'data:') {\n return Promise.resolve(undefined);\n }\n node.setAttribute(name, '');\n return resolver.resolveUrl(source).then(path => {\n return resolver.getDownloadUrl(path);\n }).then(url => {\n // Bust caching for local src attrs.\n // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Bypassing_the_cache\n url += ((/\\?/).test(url) ? '&' : '?') + (new Date()).getTime();\n node.setAttribute(name, url);\n }).catch(err => {\n // If there was an error getting the url,\n // just make it an empty link.\n node.setAttribute(name, '');\n });\n }\n\n /**\n * Handle an anchor node.\n */\n function handleAnchor(anchor: HTMLAnchorElement, resolver: IRenderMime.IResolver, linkHandler: IRenderMime.ILinkHandler | null): Promise<void> {\n // Get the link path without the location prepended.\n // (e.g. \"./foo.md#Header 1\" vs \"http://localhost:8888/foo.md#Header 1\")\n let href = anchor.getAttribute('href');\n // Bail if it is not a file-like url.\n if (!href || href.indexOf('://') !== -1 && href.indexOf('//') === 0) {\n return Promise.resolve(undefined);\n }\n // Remove the hash until we can handle it.\n let hash = anchor.hash;\n if (hash) {\n // Handle internal link in the file.\n if (hash === href) {\n anchor.target = '_self';\n return Promise.resolve(undefined);\n }\n // For external links, remove the hash until we have hash handling.\n href = href.replace(hash, '');\n }\n // Get the appropriate file path.\n return resolver.resolveUrl(href).then(path => {\n // Handle the click override.\n if (linkHandler && URLExt.isLocal(path)) {\n linkHandler.handleLink(anchor, path);\n }\n // Get the appropriate file download path.\n return resolver.getDownloadUrl(path);\n }).then(url => {\n // Set the visible anchor.\n anchor.href = url + hash;\n }).catch(err => {\n // If there was an error getting the url,\n // just make it an empty link.\n anchor.href = '';\n });\n }\n\n let markedInitialized = false;\n\n /**\n * Support GitHub flavored Markdown, leave sanitizing to external library.\n */\n function initializeMarked(): void {\n if (markedInitialized) {\n return;\n }\n markedInitialized = true;\n marked.setOptions({\n gfm: true,\n sanitize: false,\n tables: true,\n // breaks: true; We can't use GFM breaks as it causes problems with tables\n langPrefix: `cm-s-${CodeMirrorEditor.defaultConfig.theme} language-`,\n highlight: (code, lang, callback) => {\n let cb = (err: Error | null, code: string) => {\n if (callback) {\n callback(err, code);\n }\n return code;\n };\n if (!lang) {\n // no language, no highlight\n return cb(null, code);\n }\n Mode.ensure(lang).then(spec => {\n let el = document.createElement('div');\n if (!spec) {\n console.log(`No CodeMirror mode: ${lang}`);\n return cb(null, code);\n }\n try {\n Mode.run(code, spec.mime, el);\n return cb(null, el.innerHTML);\n } catch (err) {\n console.log(`Failed to highlight ${lang} code`, err);\n return cb(err, code);\n }\n }).catch(err => {\n console.log(`No CodeMirror mode: ${lang}`);\n console.log(`Require CodeMirror mode error: ${err}`);\n return cb(null, code);\n });\n return code;\n }\n });\n }\n}\n"]}
package/lib/widgets.js CHANGED
@@ -262,11 +262,7 @@ var RenderedSVG = /** @class */ (function (_super) {
262
262
  host: this.node,
263
263
  source: String(model.data[this.mimeType]),
264
264
  trusted: model.trusted,
265
- resolver: this.resolver,
266
- linkHandler: this.linkHandler,
267
- shouldTypeset: this.isAttached,
268
- unconfined: metadata && metadata.unconfined,
269
- latexTypesetter: this.latexTypesetter
265
+ unconfined: metadata && metadata.unconfined
270
266
  });
271
267
  };
272
268
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"widgets.js","sourceRoot":"","sources":["../../../../rendermime/src/widgets.ts"],"names":[],"mappings":";;;;;;;;;;;;AAgBA,6CAE2B;AAE3B,uCACqB;AAGrB;;GAEG;AACH;IACsC,kCAAM;IAC1C;;;;OAIG;IACH,wBAAY,OAAqC;QAAjD,YACE,iBAAO,SAOR;QANC,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,KAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,KAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,KAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;QAC/C,KAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,KAAI,CAAC,QAAQ,CAAC;;IAChD,CAAC;IA2BD;;;;;;OAMG;IACH,oCAAW,GAAX,UAAY,KAA6B;QACvC,uDAAuD;QAEvD,0CAA0C;QAC1C,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAElD,6BAA6B;QAC7B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAUH,qBAAC;AAAD,CAAC,AAnED,CACsC,gBAAM,GAkE3C;AAlEc,wCAAc;AAqE7B;;GAEG;AACH;IAC0C,sCAAc;IACtD;;;;OAIG;IACH,4BAAY,OAAqC;QAAjD,YACE,kBAAM,OAAO,CAAC,SAEf;QADC,KAAI,CAAC,QAAQ,CAAC,uBAAu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;IACH,4BAAY,OAAqC;QAAjD,YACE,kBAAM,OAAO,CAAC,SAEf;QADC,KAAI,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAC;;IACzC,CAAC;IAED;;;;;;OAMG;IACH,mCAAM,GAAN,UAAO,KAA6B;QAClC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC;YAC1B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,6CAA6C;SACtD,CAAC,CAAC;IACL,CAAC;IACH,yBAAC;AAAD,CAAC,AAzBD,CACiC,cAAc,GAwB9C;AAxBK,gDAAkB","sourcesContent":["/*-----------------------------------------------------------------------------\n| Copyright (c) Jupyter Development Team.\n| Distributed under the terms of the Modified BSD License.\n|----------------------------------------------------------------------------*/\nimport {\n IRenderMime\n} from '@jupyterlab/rendermime-interfaces';\n\nimport {\n ReadonlyJSONObject\n} from '@phosphor/coreutils';\n\nimport {\n Message\n} from '@phosphor/messaging';\n\nimport {\n Widget\n} from '@phosphor/widgets';\n\nimport * as renderers\n from './renderers';\n\n\n/**\n * A common base class for mime renderers.\n */\nexport\nabstract class RenderedCommon extends Widget implements IRenderMime.IRenderer {\n /**\n * Construct a new rendered common widget.\n *\n * @param options - The options for initializing the widget.\n */\n constructor(options: IRenderMime.IRendererOptions) {\n super();\n this.mimeType = options.mimeType;\n this.sanitizer = options.sanitizer;\n this.resolver = options.resolver;\n this.linkHandler = options.linkHandler;\n this.latexTypesetter = options.latexTypesetter;\n this.node.dataset['mimeType'] = this.mimeType;\n }\n\n /**\n * The mimetype being rendered.\n */\n readonly mimeType: string;\n\n /**\n * The sanitizer used to sanitize untrusted html inputs.\n */\n readonly sanitizer: IRenderMime.ISanitizer;\n\n /**\n * The resolver object.\n */\n readonly resolver: IRenderMime.IResolver | null;\n\n /**\n * The link handler.\n */\n readonly linkHandler: IRenderMime.ILinkHandler | null;\n\n /**\n * The latexTypesetter.\n */\n readonly latexTypesetter: IRenderMime.ILatexTypesetter;\n\n /**\n * Render a mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n */\n renderModel(model: IRenderMime.IMimeModel): Promise<void> {\n // TODO compare model against old model for early bail?\n\n // Toggle the trusted class on the widget.\n this.toggleClass('jp-mod-trusted', model.trusted);\n\n // Render the actual content.\n return this.render(model);\n }\n\n /**\n * Render the mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n */\n abstract render(model: IRenderMime.IMimeModel): Promise<void>;\n}\n\n\n/**\n * A common base class for HTML mime renderers.\n */\nexport\nabstract class RenderedHTMLCommon extends RenderedCommon {\n /**\n * Construct a new rendered HTML common widget.\n *\n * @param options - The options for initializing the widget.\n */\n constructor(options: IRenderMime.IRendererOptions) {\n super(options);\n this.addClass('jp-RenderedHTMLCommon');\n }\n}\n\n\n/**\n * A mime renderer for displaying HTML and math.\n */\nexport\nclass RenderedHTML extends RenderedHTMLCommon {\n /**\n * Construct a new rendered HTML widget.\n *\n * @param options - The options for initializing the widget.\n */\n constructor(options: IRenderMime.IRendererOptions) {\n super(options);\n this.addClass('jp-RenderedHTML');\n }\n\n /**\n * Render a mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n */\n render(model: IRenderMime.IMimeModel): Promise<void> {\n return renderers.renderHTML({\n host: this.node,\n source: String(model.data[this.mimeType]),\n trusted: model.trusted,\n resolver: this.resolver,\n sanitizer: this.sanitizer,\n linkHandler: this.linkHandler,\n shouldTypeset: this.isAttached,\n latexTypesetter: this.latexTypesetter\n });\n }\n\n /**\n * A message handler invoked on an `'after-attach'` message.\n */\n onAfterAttach(msg: Message): void {\n if (this.latexTypesetter) {\n this.latexTypesetter.typeset(this.node);\n }\n }\n}\n\n\n/**\n * A mime renderer for displaying LaTeX output.\n */\nexport\nclass RenderedLatex extends RenderedCommon {\n /**\n * Construct a new rendered LaTeX widget.\n *\n * @param options - The options for initializing the widget.\n */\n constructor(options: IRenderMime.IRendererOptions) {\n super(options);\n this.addClass('jp-RenderedLatex');\n }\n\n /**\n * Render a mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n */\n render(model: IRenderMime.IMimeModel): Promise<void> {\n return renderers.renderLatex({\n host: this.node,\n source: String(model.data[this.mimeType]),\n shouldTypeset: this.isAttached,\n latexTypesetter: this.latexTypesetter\n });\n }\n\n /**\n * A message handler invoked on an `'after-attach'` message.\n */\n onAfterAttach(msg: Message): void {\n if (this.latexTypesetter) {\n this.latexTypesetter.typeset(this.node);\n }\n }\n}\n\n\n/**\n * A mime renderer for displaying images.\n */\nexport\nclass RenderedImage extends RenderedCommon {\n /**\n * Construct a new rendered image widget.\n *\n * @param options - The options for initializing the widget.\n */\n constructor(options: IRenderMime.IRendererOptions) {\n super(options);\n this.addClass('jp-RenderedImage');\n }\n\n /**\n * Render a mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n */\n render(model: IRenderMime.IMimeModel): Promise<void> {\n let metadata = model.metadata[this.mimeType] as ReadonlyJSONObject;\n return renderers.renderImage({\n host: this.node,\n mimeType: this.mimeType,\n source: String(model.data[this.mimeType]),\n width: metadata && metadata.width as number | undefined,\n height: metadata && metadata.height as number | undefined,\n unconfined: metadata && metadata.unconfined as boolean | undefined\n });\n }\n}\n\n\n/**\n * A mime renderer for displaying Markdown with embeded latex.\n */\nexport\nclass RenderedMarkdown extends RenderedHTMLCommon {\n /**\n * Construct a new rendered markdown widget.\n *\n * @param options - The options for initializing the widget.\n */\n constructor(options: IRenderMime.IRendererOptions) {\n super(options);\n this.addClass('jp-RenderedMarkdown');\n }\n\n /**\n * Render a mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n */\n render(model: IRenderMime.IMimeModel): Promise<void> {\n return renderers.renderMarkdown({\n host: this.node,\n source: String(model.data[this.mimeType]),\n trusted: model.trusted,\n resolver: this.resolver,\n sanitizer: this.sanitizer,\n linkHandler: this.linkHandler,\n shouldTypeset: this.isAttached,\n latexTypesetter: this.latexTypesetter,\n });\n }\n\n /**\n * A message handler invoked on an `'after-attach'` message.\n */\n onAfterAttach(msg: Message): void {\n if (this.latexTypesetter) {\n this.latexTypesetter.typeset(this.node);\n }\n }\n}\n\n\n/**\n * A widget for displaying SVG content.\n */\nexport\nclass RenderedSVG extends RenderedCommon {\n /**\n * Construct a new rendered SVG widget.\n *\n * @param options - The options for initializing the widget.\n */\n constructor(options: IRenderMime.IRendererOptions) {\n super(options);\n this.addClass('jp-RenderedSVG');\n }\n\n /**\n * Render a mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n */\n render(model: IRenderMime.IMimeModel): Promise<void> {\n let metadata = model.metadata[this.mimeType] as ReadonlyJSONObject;\n return renderers.renderSVG({\n host: this.node,\n source: String(model.data[this.mimeType]),\n trusted: model.trusted,\n resolver: this.resolver,\n linkHandler: this.linkHandler,\n shouldTypeset: this.isAttached,\n unconfined: metadata && metadata.unconfined as boolean | undefined,\n latexTypesetter: this.latexTypesetter\n });\n }\n\n /**\n * A message handler invoked on an `'after-attach'` message.\n */\n onAfterAttach(msg: Message): void {\n if (this.latexTypesetter) {\n this.latexTypesetter.typeset(this.node);\n }\n }\n}\n\n\n/**\n * A widget for displaying plain text and console text.\n */\nexport\nclass RenderedText extends RenderedCommon {\n /**\n * Construct a new rendered text widget.\n *\n * @param options - The options for initializing the widget.\n */\n constructor(options: IRenderMime.IRendererOptions) {\n super(options);\n this.addClass('jp-RenderedText');\n }\n\n /**\n * Render a mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n */\n render(model: IRenderMime.IMimeModel): Promise<void> {\n return renderers.renderText({\n host: this.node,\n source: String(model.data[this.mimeType])\n });\n }\n}\n\n\n/**\n * A widget for displaying deprecated JavaScript output.\n */\nexport\nclass RenderedJavaScript extends RenderedCommon {\n /**\n * Construct a new rendered text widget.\n *\n * @param options - The options for initializing the widget.\n */\n constructor(options: IRenderMime.IRendererOptions) {\n super(options);\n this.addClass('jp-RenderedJavaScript');\n }\n\n /**\n * Render a mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n */\n render(model: IRenderMime.IMimeModel): Promise<void> {\n return renderers.renderText({\n host: this.node,\n source: 'JavaScript output is disabled in JupyterLab'\n });\n }\n}\n"]}
1
+ {"version":3,"file":"widgets.js","sourceRoot":"","sources":["../../../../rendermime/src/widgets.ts"],"names":[],"mappings":";;;;;;;;;;;;AAgBA,6CAE2B;AAE3B,uCACqB;AAGrB;;GAEG;AACH;IACsC,kCAAM;IAC1C;;;;OAIG;IACH,wBAAY,OAAqC;QAAjD,YACE,iBAAO,SAOR;QANC,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,KAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,KAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,KAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;QAC/C,KAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,KAAI,CAAC,QAAQ,CAAC;;IAChD,CAAC;IA2BD;;;;;;OAMG;IACH,oCAAW,GAAX,UAAY,KAA6B;QACvC,uDAAuD;QAEvD,0CAA0C;QAC1C,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAElD,6BAA6B;QAC7B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAUH,qBAAC;AAAD,CAAC,AAnED,CACsC,gBAAM,GAkE3C;AAlEc,wCAAc;AAqE7B;;GAEG;AACH;IAC0C,sCAAc;IACtD;;;;OAIG;IACH,4BAAY,OAAqC;QAAjD,YACE,kBAAM,OAAO,CAAC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;IACzC,CAAC;IAED;;;;;;OAMG;IACH,mCAAM,GAAN,UAAO,KAA6B;QAClC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC;YAC1B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,6CAA6C;SACtD,CAAC,CAAC;IACL,CAAC;IACH,yBAAC;AAAD,CAAC,AAzBD,CACiC,cAAc,GAwB9C;AAxBK,gDAAkB","sourcesContent":["/*-----------------------------------------------------------------------------\n| Copyright (c) Jupyter Development Team.\n| Distributed under the terms of the Modified BSD License.\n|----------------------------------------------------------------------------*/\nimport {\n IRenderMime\n} from '@jupyterlab/rendermime-interfaces';\n\nimport {\n ReadonlyJSONObject\n} from '@phosphor/coreutils';\n\nimport {\n Message\n} from '@phosphor/messaging';\n\nimport {\n Widget\n} from '@phosphor/widgets';\n\nimport * as renderers\n from './renderers';\n\n\n/**\n * A common base class for mime renderers.\n */\nexport\nabstract class RenderedCommon extends Widget implements IRenderMime.IRenderer {\n /**\n * Construct a new rendered common widget.\n *\n * @param options - The options for initializing the widget.\n */\n constructor(options: IRenderMime.IRendererOptions) {\n super();\n this.mimeType = options.mimeType;\n this.sanitizer = options.sanitizer;\n this.resolver = options.resolver;\n this.linkHandler = options.linkHandler;\n this.latexTypesetter = options.latexTypesetter;\n this.node.dataset['mimeType'] = this.mimeType;\n }\n\n /**\n * The mimetype being rendered.\n */\n readonly mimeType: string;\n\n /**\n * The sanitizer used to sanitize untrusted html inputs.\n */\n readonly sanitizer: IRenderMime.ISanitizer;\n\n /**\n * The resolver object.\n */\n readonly resolver: IRenderMime.IResolver | null;\n\n /**\n * The link handler.\n */\n readonly linkHandler: IRenderMime.ILinkHandler | null;\n\n /**\n * The latexTypesetter.\n */\n readonly latexTypesetter: IRenderMime.ILatexTypesetter;\n\n /**\n * Render a mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n */\n renderModel(model: IRenderMime.IMimeModel): Promise<void> {\n // TODO compare model against old model for early bail?\n\n // Toggle the trusted class on the widget.\n this.toggleClass('jp-mod-trusted', model.trusted);\n\n // Render the actual content.\n return this.render(model);\n }\n\n /**\n * Render the mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n */\n abstract render(model: IRenderMime.IMimeModel): Promise<void>;\n}\n\n\n/**\n * A common base class for HTML mime renderers.\n */\nexport\nabstract class RenderedHTMLCommon extends RenderedCommon {\n /**\n * Construct a new rendered HTML common widget.\n *\n * @param options - The options for initializing the widget.\n */\n constructor(options: IRenderMime.IRendererOptions) {\n super(options);\n this.addClass('jp-RenderedHTMLCommon');\n }\n}\n\n\n/**\n * A mime renderer for displaying HTML and math.\n */\nexport\nclass RenderedHTML extends RenderedHTMLCommon {\n /**\n * Construct a new rendered HTML widget.\n *\n * @param options - The options for initializing the widget.\n */\n constructor(options: IRenderMime.IRendererOptions) {\n super(options);\n this.addClass('jp-RenderedHTML');\n }\n\n /**\n * Render a mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n */\n render(model: IRenderMime.IMimeModel): Promise<void> {\n return renderers.renderHTML({\n host: this.node,\n source: String(model.data[this.mimeType]),\n trusted: model.trusted,\n resolver: this.resolver,\n sanitizer: this.sanitizer,\n linkHandler: this.linkHandler,\n shouldTypeset: this.isAttached,\n latexTypesetter: this.latexTypesetter\n });\n }\n\n /**\n * A message handler invoked on an `'after-attach'` message.\n */\n onAfterAttach(msg: Message): void {\n if (this.latexTypesetter) {\n this.latexTypesetter.typeset(this.node);\n }\n }\n}\n\n\n/**\n * A mime renderer for displaying LaTeX output.\n */\nexport\nclass RenderedLatex extends RenderedCommon {\n /**\n * Construct a new rendered LaTeX widget.\n *\n * @param options - The options for initializing the widget.\n */\n constructor(options: IRenderMime.IRendererOptions) {\n super(options);\n this.addClass('jp-RenderedLatex');\n }\n\n /**\n * Render a mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n */\n render(model: IRenderMime.IMimeModel): Promise<void> {\n return renderers.renderLatex({\n host: this.node,\n source: String(model.data[this.mimeType]),\n shouldTypeset: this.isAttached,\n latexTypesetter: this.latexTypesetter\n });\n }\n\n /**\n * A message handler invoked on an `'after-attach'` message.\n */\n onAfterAttach(msg: Message): void {\n if (this.latexTypesetter) {\n this.latexTypesetter.typeset(this.node);\n }\n }\n}\n\n\n/**\n * A mime renderer for displaying images.\n */\nexport\nclass RenderedImage extends RenderedCommon {\n /**\n * Construct a new rendered image widget.\n *\n * @param options - The options for initializing the widget.\n */\n constructor(options: IRenderMime.IRendererOptions) {\n super(options);\n this.addClass('jp-RenderedImage');\n }\n\n /**\n * Render a mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n */\n render(model: IRenderMime.IMimeModel): Promise<void> {\n let metadata = model.metadata[this.mimeType] as ReadonlyJSONObject;\n return renderers.renderImage({\n host: this.node,\n mimeType: this.mimeType,\n source: String(model.data[this.mimeType]),\n width: metadata && metadata.width as number | undefined,\n height: metadata && metadata.height as number | undefined,\n unconfined: metadata && metadata.unconfined as boolean | undefined\n });\n }\n}\n\n\n/**\n * A mime renderer for displaying Markdown with embeded latex.\n */\nexport\nclass RenderedMarkdown extends RenderedHTMLCommon {\n /**\n * Construct a new rendered markdown widget.\n *\n * @param options - The options for initializing the widget.\n */\n constructor(options: IRenderMime.IRendererOptions) {\n super(options);\n this.addClass('jp-RenderedMarkdown');\n }\n\n /**\n * Render a mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n */\n render(model: IRenderMime.IMimeModel): Promise<void> {\n return renderers.renderMarkdown({\n host: this.node,\n source: String(model.data[this.mimeType]),\n trusted: model.trusted,\n resolver: this.resolver,\n sanitizer: this.sanitizer,\n linkHandler: this.linkHandler,\n shouldTypeset: this.isAttached,\n latexTypesetter: this.latexTypesetter,\n });\n }\n\n /**\n * A message handler invoked on an `'after-attach'` message.\n */\n onAfterAttach(msg: Message): void {\n if (this.latexTypesetter) {\n this.latexTypesetter.typeset(this.node);\n }\n }\n}\n\n\n/**\n * A widget for displaying SVG content.\n */\nexport\nclass RenderedSVG extends RenderedCommon {\n /**\n * Construct a new rendered SVG widget.\n *\n * @param options - The options for initializing the widget.\n */\n constructor(options: IRenderMime.IRendererOptions) {\n super(options);\n this.addClass('jp-RenderedSVG');\n }\n\n /**\n * Render a mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n */\n render(model: IRenderMime.IMimeModel): Promise<void> {\n let metadata = model.metadata[this.mimeType] as ReadonlyJSONObject;\n return renderers.renderSVG({\n host: this.node,\n source: String(model.data[this.mimeType]),\n trusted: model.trusted,\n unconfined: metadata && metadata.unconfined as boolean | undefined\n });\n }\n\n /**\n * A message handler invoked on an `'after-attach'` message.\n */\n onAfterAttach(msg: Message): void {\n if (this.latexTypesetter) {\n this.latexTypesetter.typeset(this.node);\n }\n }\n}\n\n\n/**\n * A widget for displaying plain text and console text.\n */\nexport\nclass RenderedText extends RenderedCommon {\n /**\n * Construct a new rendered text widget.\n *\n * @param options - The options for initializing the widget.\n */\n constructor(options: IRenderMime.IRendererOptions) {\n super(options);\n this.addClass('jp-RenderedText');\n }\n\n /**\n * Render a mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n */\n render(model: IRenderMime.IMimeModel): Promise<void> {\n return renderers.renderText({\n host: this.node,\n source: String(model.data[this.mimeType])\n });\n }\n}\n\n\n/**\n * A widget for displaying deprecated JavaScript output.\n */\nexport\nclass RenderedJavaScript extends RenderedCommon {\n /**\n * Construct a new rendered text widget.\n *\n * @param options - The options for initializing the widget.\n */\n constructor(options: IRenderMime.IRendererOptions) {\n super(options);\n this.addClass('jp-RenderedJavaScript');\n }\n\n /**\n * Render a mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n */\n render(model: IRenderMime.IMimeModel): Promise<void> {\n return renderers.renderText({\n host: this.node,\n source: 'JavaScript output is disabled in JupyterLab'\n });\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyterlab/rendermime",
3
- "version": "0.15.4",
3
+ "version": "0.16.3",
4
4
  "description": "JupyterLab - RenderMime",
5
5
  "homepage": "https://github.com/jupyterlab/jupyterlab",
6
6
  "bugs": {
@@ -30,17 +30,17 @@
30
30
  "watch": "tsc -w"
31
31
  },
32
32
  "dependencies": {
33
- "@jupyterlab/apputils": "^0.15.4",
34
- "@jupyterlab/codemirror": "^0.15.4",
35
- "@jupyterlab/coreutils": "^1.0.6",
36
- "@jupyterlab/observables": "^1.0.6",
37
- "@jupyterlab/rendermime-interfaces": "^1.0.6",
38
- "@jupyterlab/services": "^1.1.4",
33
+ "@jupyterlab/apputils": "^0.16.4",
34
+ "@jupyterlab/codemirror": "^0.16.3",
35
+ "@jupyterlab/coreutils": "^1.1.3",
36
+ "@jupyterlab/observables": "^1.0.10",
37
+ "@jupyterlab/rendermime-interfaces": "^1.0.10",
38
+ "@jupyterlab/services": "^2.0.3",
39
39
  "@phosphor/coreutils": "^1.3.0",
40
40
  "@phosphor/messaging": "^1.2.2",
41
41
  "@phosphor/signaling": "^1.2.2",
42
42
  "@phosphor/widgets": "^1.5.0",
43
- "ansi_up": "~1.3.0",
43
+ "ansi_up": "^3.0.0",
44
44
  "marked": "~0.3.9"
45
45
  },
46
46
  "devDependencies": {
package/style/index.css CHANGED
@@ -19,6 +19,7 @@
19
19
 
20
20
 
21
21
  .jp-RenderedText pre,
22
+ .jp-RenderedJavaScript pre,
22
23
  .jp-RenderedHTMLCommon pre {
23
24
  color: var(--jp-content-font-color1);
24
25
  border: none;