HTML2MD attempts to convert HTML into Markdown by reducing an HTML document into simple, Markdown-compatible parts. This library is compatible with both browsers and Node.js.
HTML2MD does its best job to convert any HTML given to it and it is by no means perfect. Heavily formatted documents, for example, will likely fail to convert properly. A few assumptions are made about the HTML which outline its limitations:
Download the latest version from our release page and use via a script tag. The variable html2md
will be attached to window
.
<script type="text/javascript" src="html2md.js"></script>
If using Browserify or Node.js, you can install via NPM and use via require("html2md")
.
$ npm install html2md
Using HTML2MD is really easy; it's just a function!
var markdown = html2md("<h1>Hello World</h1>");
console.log(markdown); // -> # Hello World
Please see the documentation for specifics.
HTML2MD uses Grunt to build a Browserify bundle from the original source found in lib/
. When the command below completes, the compiled source will be saved to dist/
directory.
npm install && grunt
If you don't the Grunt cli tools installed globally, run npm install -g grunt-cli
before running that command.
HTML2MD has several unit tests written for Node.js and the browser. Before running tests, install all test dependencies:
npm install
To get tests running on Node.js, run:
npm test
To run tests in the browser, start a test server with this command. When the server is running, navigate your browser to http://localhost:8000.
npm run dev
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。