npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@luminati-io/mhtml2html

v3.0.0-lum.1

Published

Converts an mhtml document to a single html document

Downloads

78

Readme

mhtml2html.js

npm version circleci

mhtml2html converts MHTML files to a single HTML file using javascript.

Usage | API | Development

Usage

mhtml2html is compatible with Node >= v10.

It has only been tested with MHTML files built and used with the latest versions of Chrome

Node.js Example

mhtml2html can be used via the command line (use the --help flag to view all options):

$ mhtml2html <input.mhtml> <output.html>

For programmatic usage, mhtml2html can be used provided a WHATWG DOM parser implementation (e.g jsdom):

const mhtml2html = require('mhtml2html');
const { JSDOM } = require('jsdom');

const mhtml = '<your MHTML string>';
const htmlDoc = mhtml2html.convert(mhtml, { parseDOM: (html) => new JSDOM(html) });
console.log(htmlDoc);

Browser Example

To get started, import mhtml2html:

import mhtml2html from 'mhtml2html';

Or include it as a script in your webpage:

<script src="https://unpkg.com/mhtml2html@<VERSION>" type="javascript" />

By default, mhtml2html will use the DOMParser available in most browsers:

import mhtml2html from 'mhtml2html';

const mhtml = '<your MHTML string>';
const html = mhtml2html.convert(mhtml);
console.log(html);

API

parse

mhtml2html.parse(mhtml, { htmlOnly = false, parseDOM = <function> });

  • mhtml: An MHTML String.
  • options.htmlOnly: If set to true, returns the html document without resources.
  • options.parseDOM: A callback that accepts a DOM string and returns a window object (defaults to DOMParser only available in browsers).
  • Returns an html document without resources if htmlOnly is set to true. Otherwise it returns an MHTML parsed object:
{
    "index" : "<html-index-url>",
    "media": {
        "<asset-url>" : {
            "data" : "<resource-string>",
            "id": "<frame-id>",
            "type": "<resource-type>",
            "encoding": "<resource-encoding>"
        }
    },
    "frames": {
        "<frame-id>": {
            "data": "<resource-string>",
            "id": "<frame-id>",
            "type:": "<resource-type>",
            "encoding": "<resource-encoding>"
        }
    }
}

convert

mhtml2html.convert(mhtml, { convertIframes = false, parseDOM = <function> });

  • mhtml: An MHTML String or MHTML parsed object.
  • options.convertIframes: Whether or not to include iframes in the converted response (defaults to false).
  • options.parseDOM: A callback that accepts a DOM string and returns a window object (defaults to DOMParser only available in browsers).
  • Returns an html window element.

Development

Requirements

  • Node.js >= 10
  • Yarn

To build and test mhtml2html:

  1. If node_modules haven't been installed already, run yarn install from the root directory.
  2. Run yarn test to build and test the source code.

License

Released under the MIT License