• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

kates/html2markdown: Converts HTML to Markdown

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

kates/html2markdown

开源软件地址(OpenSource Url):

https://github.com/kates/html2markdown

开源编程语言(OpenSource Language):

JavaScript 95.6%

开源软件介绍(OpenSource Introduction):

HTML2Markdown

Javascript implementation for converting HTML to Markdown text. Browser and Node.js support.

Installation

npm install html2markdown

Usage in node.js

var html2markdown = require('html2markdown');

console.log(html2markdown('<h1>Hello markdown!</h1>'));

Usage in browser

<script type="text/javascript" src="markdown_dom_parser.js"></script>
<script type="text/javascript" src="html2markdown.js"></script>

console.log(html2markdown("<h1>Hello markdown!</h1>"))

This call will return convert the html and return the mardown string like ""# H1\n\n"

Changes in this implementation

  • Added new htmldomparser. A simple html parser implementation that assumes parsing is done in browser. Shold be compatible with john Resig's parser.
  • Parser implementation provided support for ignoring tags that you do not want to convert.
  • Parser also has an option to ignore dom elements with hidden styles.
  • Added rules for parsing PRE, CODE, SPAN, DIV, TD, DL, DT
  • Added support for ignoring tags that you do not want to convert.
  • Improved "startBlock" method and renamed it to "block"
  • Added support for nested lists
  • Fixed some showdown rendering issues when a link has a nested image
  • Some readability changes like collapse whitespace, treat images as block elements, do not output text if elements are empty.
  • Added support for converting relative url's to absolute url's
  • Dropped wordwrap function as it does not seem a good idea to introduce new lines in the converter. and wordwrap behaviro was not consistents as elements can be nested.
  • Added support for refeence style images and links (option driven to choose between inline markdown formatting and refernce style formatting)
  • Added ton's of unit tests.

Known conversion issues

If HTML tag is of following form. Then, currently showdown fails to render

    <a href="/some_link">
        <h1>
                <img src="/some_image_lin"/>
        </h1>
    </a>

Testing

In Node.js

npm install
npm test

In Browser

Just open SpecRunner.html in your browser.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
syntax-tree/mdast: Markdown Abstract Syntax Tree format发布时间:2022-08-18
下一篇:
fei0810/markdownhere4zotero: markdown here zotero 插件发布时间:2022-08-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap