Skip to content

Commit

Permalink
M README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer committed Dec 25, 2020
1 parent c0311fe commit c94ac7b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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

| | md源文件 | 导入知乎的效果 |
|:-- | :-: | :-: |
|使用前 | ![](assets/md.png) | ![](assets/before.png) |
|转换后 | ![](assets/built.png) | ![](assets/after.png) |


## Install

```sh
Expand All @@ -14,34 +20,37 @@ pip install md2zhihu
md2zhihu your_great_work.md
```

这个命令将markdown 转换成 知乎 文章编辑器可直接导入的格式, 存储到 `_md2/your_great_work/your_great_work.md`.
`-o` 选项可以用来调整输出目录.
这个命令将markdown 转换成 知乎 文章编辑器可直接导入的格式, 存储到 `_md2/your_great_work/your_great_work.md`. 转换后的markdown文档不依赖任何本地的图片文件或其他文件.

- `-o` 指定输出目录, 默认为`./_md2/`.

- `-r` 指定用于存储图片等资源的git repo url; 要求是对这个repo有push权限.

例如要将图片等上传到`github.com/openacid/foo`项目中:
```
md2zhihu great.md -r https://github.com/openacid/foo.git
```
默认使用当前目录下的git配置, (作者假设用户用git来保存自己的工作:DDD), md2zhihu 将建立一个随机分支来保存所有图片.
## Requirements
```
# For rendering table to html
brew install pandoc
brew install pandoc imagemagick
```
## Features
- 公式转换:
例如

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

<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">

例如 ` $$ ||X{\vec {\beta }}-Y||^{2} $$ `
![](https://www.zhihu.com/equation?tex=%7C%7CX%7B%5Cvec%20%7B%5Cbeta%20%7D%7D-Y%7C%7C%5E%7B2%7D)
转换成可以直接被知乎使用的tex渲染引擎的引用:
```
<img src="https://www.zhihu.com/equation?tex=||X{\vec {\beta }}-Y||^{2}\\" alt="||X{\vec {\beta }}-Y||^{2}\\" class="ee_img tr_noresize" eeimg="1">
<img src="https://www.zhihu.com/equation?tex=||X{\vec {\beta }}-Y||^{2}\\" ...>
```
- 自动识别block的公式和inline的公式.
Expand All @@ -50,12 +59,6 @@ brew install pandoc
- 图片: md2zhihu 将图片上传到github, 并将markdown中的图片引用做替换.
- 默认命令例如`md2zhihu your_great_work.md`要求当前工作目录是一个git(作者假设用户用git来保存自己的工作), md2zhihu将建立一个随机分支来保存所有图片.

- 也可以使用指定的git repo来保存图片, 例如使用`github.com/openacid/openacid.github.io` 这个repo来保存图片:

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

## Limitation
- 知乎的表格不支持table cell 中的markdown格式, 例如表格中的超链接, 无法渲染, 会被知乎转成纯文本.
Expand Down
Binary file added assets/after.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/before.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/built.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/md.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c94ac7b

Please sign in to comment.