Skip to content

Commit

Permalink
SVG namespace. Fixes jupyterlab#6295.
Browse files Browse the repository at this point in the history
  • Loading branch information
zerline committed Jun 4, 2019
1 parent 3eb6eaa commit 75084fa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/rendermime/src/renderers.ts
Expand Up @@ -418,6 +418,12 @@ export function renderSVG(options: renderSVG.IRenderOptions): Promise<void> {
return Promise.resolve(undefined);
}

// Add missing SVG namespace (if actually missing)
var patt = '<svg[^>]+xmlns=[^>]+svg';
if (source.search(patt) < 0) {
source = source.replace('<svg', '<svg xmlns="http://www.w3.org/2000/svg"');
}

// Render in img so that user can save it easily
const img = new Image();
img.src = `data:image/svg+xml,${encodeURIComponent(source)}`;
Expand Down

0 comments on commit 75084fa

Please sign in to comment.