Code Monkey home page Code Monkey logo

html2md's Introduction

html2md

convert html to markdown

在GitHub上搜了下HTML转markdown的工具,并按照star从高到低逐个试了下,感觉不怎么符合自己的预期,索性自己写一个。

HTML标签

并不是对所有的标签都做处理,比如preblockquotecode标签,这些没转成```> 或者是 `,因为markdown解析器解析不会有问题。

处理的标签

  • h1~h6
  • del
  • b
  • strong
  • i
  • em
  • dfn
  • var
  • cite
  • br
  • span
  • div
  • figure
  • p
  • article
  • nav
  • footer
  • header
  • section
  • table、thead、tbody、tr、th、td
  • ul、ol、li
  • hr

不作处理的标签

  • pre
  • blockquote
  • code

转化效果

为了测试转化效果,我分别从github.io、gitbook、readthedoc三个站点随便提取了个正文的HTML内容,然后并将其转成markdown,看了下效果,比较符合自己的预期。 当然,效果并不可能是100%的。

使用方法

go语言使用

  1. 安装 go get github.com/TruthHun/html2md
  2. 引入和调用
mdStr:=html2md.Convert(htmlStr)

其他

已经编译打包了win、mac和linux的64位的可执行文件,在bin目录下

windows使用:

html2md.exe input.html output.md

mac/linux使用:

html2md input.html output.md

其它语言,直接使用cmd调用二进制可执行文件对文档进行处理即可

支持我

如果您使用了当前包或程序,遇到问题,向我反馈就是对我最好的支持;如果项目帮到了您,给当前项目一个star,也是对我莫大的认可与支持。

html2md's People

Contributors

truthhun avatar truthhun88 avatar

Watchers

 avatar  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.