Skip to content

Commit

Permalink
it works!
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer committed Dec 23, 2020
1 parent 3574b8e commit a3e687b
Show file tree
Hide file tree
Showing 6 changed files with 348 additions and 182 deletions.
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,56 @@
# md2zhihu
Convert markdown to zhihu compatible format

将markdown转换成 知乎 兼容的 markdown 格式

## Install

```sh
pip install md2zhihu
```

## Usage

```sh
md2zhihu your_great_work.md
```

这个命令将markdown 转换成 知乎 文章编辑器可直接导入的格式, 存储到 `_md2/your_great_work/your_great_work.md`.
`-o` 选项可以用来调整输出目录.

## Features

- 公式转换:

例如

```
$$
||X{\vec {\beta }}-Y||^{2}
$$
```

$$
||X{\vec {\beta }}-Y||^{2}
$$

转换成可以直接被知乎使用的tex渲染引擎的引用:

```
<img src="https://www.zhihu.com/equation?tex=%7C%7CX%7B%5Cvec%20%7B%5Cbeta%20%7D%7D-Y%7C%7C%5E%7B2%7D%5C%5C" alt="||X{\vec {\beta }}-Y||^{2}\\" class="ee_img tr_noresize" eeimg="1">
```

md2zhihu 能自动识别block的公式和inline的公式.

- 表格: 将markdown表格转换成html 以便支持知乎直接导入.

- 图片: md2zhihu 将图片上传到github, 并将markdown中的图片引用做替换.

- 默认命令例如`md2zhihu your_great_work.md`要求当前工作目录是一个git(作者假设用户用git来保存自己的工作), md2zhihu将建立一个随机分支来保存所有图片.

- 也可以使用指定的git repo来保存图片, 例如:

`md2zhihu your_great_work.md -r https://github.com/openacid/openacid.github.io.git `要求是对这个repo有push权限.

## Limitation

- 知乎的表格不支持table cell 中的markdown格式, 例如表格中的超链接, 无法渲染, 会被知乎转成纯文本.
3 changes: 1 addition & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
__version__ = "0.1.7"
__name__ = "md2zhihu"

from . import mistune
from . import md2zhihu
from . import mistune
from .md2zhihu import main

1 change: 1 addition & 0 deletions __main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

from .md2zhihu import main

main()
Loading

0 comments on commit a3e687b

Please sign in to comment.