html2markdown 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
html2markdown 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
html2markdown 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 GPL
操作系统 跨平台
软件类型 开源软件
开源组织
地区 国产
投 递 者 iThinker
适用人群 未知
收录时间 2016-09-29

软件简介

将HTML转化成Markdown的工具,增加了table的解析,以及更正了pre标签,此项目源于当时采集gitbook等类似平台的文章时使用!

安装

npm install h2m

注意:将项目的converters文件夹覆盖node_modules/h2m 的converters文件夹

如何使用

h2m(html[, options])

例子

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

选项

  • converter: the converter you can choose. now support CommonMark(default) and MarkdownExtra

  • overides: custom converter behavior:

h2m('<a href="http://www.baidu.com">h2m</a>', { overides: { a: function(node) { /**
          node is an object as the a tag:
          {
            name: "a",
            attrs: {
              href: 'http://www.baidu.com'
            },
            md: 'h2m'
          }
          */ return `[This is an link element](${node.attrs.href})` } } } // output [This is an link element](http://www.baidu.com)

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

展开阅读全文

代码

的 Gitee 指数为
超过 的项目

评论

点击引领话题📣 发布并加入讨论🔥
暂无内容
发表了博客
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
发表了问答
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
暂无内容
0 评论
3 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部