Convert HTML to Markdown. tomd

GPL-3.0 License
Python
跨平台
2021-12-02
首席测试

tomd

License Pypi Python

When crawling online articles such as news, blogs, etc. I want to save them in markdown files but not databases. Tomd has the ability of converting a HTML that converted from markdown. If a HTML can't be described by markdown, tomd can't convert it right. Tomd is a python tool.

Road map

  • Basic support
  • Full support(Nested list)
  • Command line tool

Installation

pip install tomd

Getting Started

Input

import tomd

tomd.Tomd('<h1>h1</h1>').markdown
# or
tomd.convert('<h1>h1</h1>')

Output

# h1

Usage

from tomd import Tomd


html="""
<h1>h1</h1>
<h2>h2</h2>
<h3>h3</h3>
<h4>h4</h4>
<h5>h5</h5>
<h6>h6</h6>
<p>paragraph
<a href="https://github.com">link</a>
<img src="https://github.com" class="dsad">img</img>
</p>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
<ol>
<li>1</li>
<li>2</li>
<li>3</li>
</ol>
<blockquote>blockquote</blockquote>
<p><code>inline code</code></p>
<pre><code>block code</code></pre>
<p>
<del>del</del>
<b>bold</b>
<i>italic</i>
<b><i>bold italic</i></b>
</p>

<hr/>

<table>
<thead>
<tr>
<th>th1</th>
<th>th2</th>
</tr>
</thead>
<tbody>
<tr>
<td>td</td>
<td>td</td>
</tr>
<tr>
<td>td</td>
<td>td</td>
</tr></tbody></table>
"""


Tomd(html).markdown

Result

# h1

## h2

### h3

#### h4

##### h5

###### h6

paragraph
[link](https://github.com)
![img](https://github.com)


- 1
- 2
- 3

1. 1
1. 2
1. 3

> blockquote

`inline code`


block code


~~del~~
**bold**
*italic*
***bold italic***


---


|th1|th2
|------
|td|td
|td|td
加载中

暂无资讯

暂无问答

XHttpPost 请求与连接超时回调

package callbak; /** * @author xulin * @see http://my.oschina.net/u/2358780 */ public interface XCallBack { /** * 执行回调方法 * * @param objects 将处理后的结果......

2016/01/09 14:33
500
1
帐号密码管理器“passManager.py”

密码管理 加密 python

2016/12/15 00:10
332
0
51单片机定时器程序设计

亲,戳上面的蓝字关注我们哦! 在我们的DIY电子时钟里,需要用到单片机定时器来做秒的显示,说是显示,其实就是实现数码管上“:”点的闪烁。这里初步定义为每秒亮1次,亮0.5秒,灭0.5秒。实...

2017/05/15 16:40
22
0
Linux kernel design patterns - part 3

In this final article we will be looking at just one design pattern. Westarted with the fine details of reference counting,zoomed out to look at whole data structures, and now m...

2014/05/12 21:30
12
0

没有更多内容

加载失败,请刷新页面

没有更多内容

返回顶部
顶部