GithubHelp home page GithubHelp logo

greatmagicianhc / h2m Goto Github PK

View Code? Open in Web Editor NEW

This project forked from island205/h2m

0.0 2.0 0.0 692 KB

Tool for converting HTML to Markdown, like html2markdown.

Home Page: http://island205.github.io/h2m/

JavaScript 80.83% CSS 0.31% HTML 18.86%

h2m's Introduction

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

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

Markdown Extra

  • ✅ Special Attributes for headers link and image
  • ✅ Fenced Code Blocks
  • ✅ dl, dt, dd Definition Lists
  • ✅ abbr Abbreviations
  • ☑️ table welcome PR.

Contribution

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

h2m's People

Contributors

island205 avatar gilbertsun avatar voischev avatar

Watchers

James Cloos avatar gnahceh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.