3 Star 2 Fork 1

Gitee 极速下载 / HTML2MD

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/BeneathTheInk/html2md
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

HTML2MD: A JavaScript HTML-to-Markdown converter

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:

  • Inline elements do not contain block elements.
  • Standard HTML block elements are used to define and separate content.

Install

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

Basic Usage

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.

Building from Scratch

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.

Running the Unit Tests

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
Copyright (c) 2015 Beneath the Ink, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

HTML2MD 是一个 HTML 转 Markdown 的 JavaScript 库 使用方法: <script type="text/javascript" src="html2 展开 收起
JavaScript 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/mirrors/HTML2MD.git
git@gitee.com:mirrors/HTML2MD.git
mirrors
HTML2MD
HTML2MD
master

搜索帮助