Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

transformime-jupyter-transformers

Package Overview
Dependencies
Maintainers
6
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

transformime-jupyter-transformers - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

25

lib/console-text.transform.js

@@ -6,21 +6,12 @@ "use strict";

});
var Convert = require('ansi-to-html');
exports.consoleTextTransform = consoleTextTransform;
var ansi_up = require('ansi_up');
var consoleTextTransform = (function () {
// Stick convert in a closure so it only gets created once.
function consoleTextTransform(mimetype, value, document) {
var el = document.createElement('pre');
var esc = ansi_up.escape_for_html(value);
el.innerHTML = ansi_up.ansi_to_html(esc);
return el;
}
var convert = new Convert({
escapeXML: true,
newLine: true
});
return function (mimetype, text, document) {
var el = document.createElement('pre');
el.innerHTML = convert.toHtml(text);
return el;
};
})();
exports.consoleTextTransform = consoleTextTransform;
consoleTextTransform.mimetype = 'jupyter/console-text';

@@ -27,0 +18,0 @@

@@ -8,9 +8,12 @@ "use strict";

function SVGTransform(mimetype, value, document) {
// Create a div and append SVG XML to that div as HTML. The SVG XML
// includes the parent SVG tag, so all we need to do is return the first
// child element of the div == svg element.
var el = document.createElement('div');
el.innerHTML = value;
return el.firstChild;
function SVGTransform(mimetype, value, doc) {
var container = doc.createElement('div');
container.innerHTML = value;
var svgElement = container.getElementsByTagName('svg')[0];
if (!svgElement) {
throw new Error("SVGTransform: Error: Failed to create <svg> element");
}
return svgElement;
}

@@ -17,0 +20,0 @@

{
"name": "transformime-jupyter-transformers",
"version": "0.4.1",
"version": "0.5.0",
"description": "Bundled transformers used for Jupyter specific output",

@@ -47,3 +47,3 @@ "main": "lib/index.js",

"dependencies": {
"ansi-to-html": "^0.3.0",
"ansi_up": "^1.3.0",
"katex": "^0.5.0",

@@ -50,0 +50,0 @@ "transformime-commonmark": "^0.1.0"

"use strict";
var Convert = require('ansi-to-html');
var ansi_up = require('ansi_up');
export var consoleTextTransform = function() {
// Stick convert in a closure so it only gets created once.
export function consoleTextTransform(mimetype, value, document) {
var el = document.createElement('pre');
var esc = ansi_up.escape_for_html(value);
el.innerHTML = ansi_up.ansi_to_html(esc);
return el;
}
let convert = new Convert({
escapeXML: true,
newLine: true
});
return function(mimetype, text, document) {
var el = document.createElement('pre');
el.innerHTML = convert.toHtml(text);
return el;
}
} ();
consoleTextTransform.mimetype = 'jupyter/console-text';

@@ -23,0 +14,0 @@

"use strict";
export function SVGTransform(mimetype, value, document) {
// Create a div and append SVG XML to that div as HTML. The SVG XML
// includes the parent SVG tag, so all we need to do is return the first
// child element of the div == svg element.
var el = document.createElement('div');
el.innerHTML = value;
return el.firstChild;
export function SVGTransform(mimetype, value, doc) {
const container = doc.createElement('div');
container.innerHTML = value;
const svgElement = container.getElementsByTagName('svg')[0];
if (!svgElement) {
throw new Error("SVGTransform: Error: Failed to create <svg> element");
}
return svgElement;
}
SVGTransform.mimetype = 'image/svg+xml';

@@ -32,2 +32,14 @@ import {assert} from 'chai';

});
it('should output the correct HTML with ansi colors', function() {
let consoleText = '\x1b[01;41;32mtext \x1b[00m';
let transformed = this.t.transform(
{'jupyter/console-text': consoleText},
this.document);
return transformed.then(({el}) => {
assert.equal(el.outerHTML, '<pre><span style="color:rgb(0, 255, 0);background-color:rgb(187, 0, 0)">text </span></pre>');
assert.equal(el.textContent, 'text ');
assert.equal(el.localName, "pre");
});
});
});

@@ -10,5 +10,3 @@ import {assert} from 'chai';

this.document = jsdom();
this.t = new Transformime([
SVGTransform
]);
this.t = new Transformime([SVGTransform]);
});

@@ -19,2 +17,17 @@

});
it('should create an svg tag', function() {
const svg = `
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
SYSTEM "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg></svg>
`;
return this.t.transform({"image/svg+xml": svg}, this.document).then(
(bundle) => {
assert.equal(bundle.el.tagName, "svg");
},
(err) => { throw err; }
);
});
});

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc