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

h2m

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

h2m

Transform HTML to markdown base on posthtml.

  • 0.5.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
395
increased by17.91%
Maintainers
1
Weekly downloads
 
Created
Source

h2m

logo

npm Build Status Coverage Status

Tool for converting HTML to Markdown, like html2markdown.

online converter: http://island205.github.io/h2m/

online converter

Install

$npm install h2m

How to use

h2m(html[, options])

example

var h2m = require('h2m')

var md = h2m('<h1>Hello World</h1>')
// md = '# Hello World'

options

  • converter: the converter you can choose. now support CommonMark(default) and MarkdownExtra
  • overides: custom converter behavior:
h2m('<a href="http://island205.github.io/h2m/">h2m</a>', {
    overides: {
        a: function(node) {
          /**
          node is an object as the a tag:
          {
            name: "a",
            attrs: {
              href: 'http://island205.github.io/h2m/'
            },
            md: 'h2m'
          }
          */
          return `[This is an link element](${node.attrs.href})`
        }
    }
}

// output [This is an link element](http://island205.github.io/h2m/)

Command Line Tool

install

$ npm install h2m -g

h2m downloads

usage

$h2m -h

Usage: h2m [options] <file>

Options:

  -h, --help     output usage information
  -V, --version  output the version number

Convert a local file:

$ h2m index.html

converting HTML to Markdown

made by [@island205](https://github.com/island205)

Can't be convert? welcome to submit an [issue](https://github.com/island205/h2m/issues/new).

Convert an online url:

$ h2m https://baidu.com

Save result:

$ h2m https://google.com > google.md

Support

h2m supports standard Markdown sytax: CommonMark now and Markdown Extra.

CommonMark

  • :white_check_mark: br
  • :white_check_mark: em
  • :white_check_mark: strong
  • :white_check_mark: code
  • :white_check_mark: a
  • :white_check_mark: img
  • :white_check_mark: hr
  • :white_check_mark: ul, ol
  • :white_check_mark: pre
  • :white_check_mark: div
  • :white_check_mark: p
  • :white_check_mark: blockquote
  • :white_check_mark: h1 ~ h6

Markdown Extra

  • :white_check_mark: Special Attributes for headers link and image
  • :white_check_mark: Fenced Code Blocks
  • :white_check_mark: dl, dt, dd Definition Lists
  • :white_check_mark: abbr Abbreviations
  • :ballot_box_with_check: table welcome PR.

Contribution

PRs are welcome to implement other extend Markdown language, like Markdown Extra, GFM and so on.

Keywords

FAQs

Package last updated on 27 Feb 2016

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