/h2md

:exclamation::exclamation::exclamation:转载利器:exclamation::exclamation::exclamation:这能将 html 中正文部分转化为 markdown :frog: :high_brightness:

Primary LanguagePythonApache License 2.0Apache-2.0

h2md

Build Status PyPI GitHub repo size GitHub PyPI - Python Version Twitter Follow

本项目目的是将html中正文部分转化为markdown文件,部分参考自 html2md,我把实现方式全改了,第一个 Python 项目,希望能给大家带来帮助。

安装

pip install -U h2md

用法

使用命令行工具:

# 转换一个文件
h2md examples/hello.html

# 从标准输入读取文件进行转换
cat examples/hello.html | h2md

使用 Python 脚本:

import h2md

html = '''
<h1>Header</h1>
<b><i>Hello</i></b> from <code>h2md</code>
<pre class="py"><code>
print('Hello')
</code></pre>
'''

md = h2md.convert(html)
print(md)

最时髦的用法:

注:使用此方法邮箱可能被保护

curl -o- https://mydream.ink/archive/iaas-faas-serverless/ | h2md # 标准输出
curl -o- https://mydream.ink/archive/iaas-faas-serverless/ | h2md > xx.md # 输出到 md 文件
curl -o- https://mydream.ink/archive/iaas-faas-serverless/ | h2md >> xx.md # 追加到 md 文件