Skip to content

gaomeng1900/mhtml2html

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MHT 2 HTML

Convert MHTML to HTML. No dependencies. Support GBK Encoding.

Ported from mhtml2html

  • remove node.js support
  • remove all dependencies
  • remove bundlers. use native mjs module
  • support GBK encoding with native TextDecoder

Usage

  • copy src/mht2html.mjs to your project, no dependencies needed
  • import convert function
import { convert } from './mht2html.mjs'

const element = convert(mhtmlText, { convertIframes: true })
const html = '<!DOCTYPE html>\n' + element.documentElement.outerHTML

GBK Encoding

import { convert } from './mht2html.mjs'

const element = convert(mhtmlText, { convertIframes: true, enc: 'gbk' })
const html =
	'<!DOCTYPE html>\n' +
	element.documentElement.outerHTML.replace(/charset=GBK/g, 'charset=utf-8')

Demo

  • npm i
  • npm start
  • check out /demo/index.html

About

Converts MHTML into single HTML using native JS.

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors

Languages

  • JavaScript 100.0%