New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

transformime

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

transformime

Transforms MIMEtypes to HTML Elements

  • 0.0.4
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

transformime

Build Status

Optimus MIME

Transforms MIMEtype+data to HTML Elements

Intended to be used in context of Jupyter and IPython projects, particularly by display areas.

Installation

npm install transformime

Usage

Transformime works in the browser (via browserify) and with jsdom!

Using with jsdom

> var jsdom = require('jsdom')
> var document = jsdom.jsdom() // could use window.document
> var Transformime = require('transformime').Transformime;
> var transformer = new Transformime();
> var el = transformer.transform("<h1>Woo</h1>", "text/html", document)
> el.innerHTML
'<h1>Woo</h1>'
> el.textContent
'Woo'

Images get handled as base64 encoded data and become embedded elements.

> // Send an image over
> el = transformer.transform("R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", "image/png", document)
> el.src
'data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'

Working with iframes

> // Assume document is defined (either in browser or from jsdom) as well as transformer
> // Create an arbitrary iframe and slap it in the body of the document
> var iframe = document.createElement("iframe");
> document.querySelector('body').appendChild(iframe);
> var idoc = iframe.contentDocument;
> var el = transformer.transform('<h1>mimetic</h1>', "text/html", idoc);
> idoc.querySelector('body').appendChild(el);
> idoc.querySelector('body').innerHTML
'<div><h1>mimetic</h1></div>'

Development

git clone https://github.com/nteract/transformime
cd transformime
npm install
npm run build

Keywords

FAQs

Package last updated on 16 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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