Skip to content

Commit 57b1441

Browse files
committed
Use HTML tag for text mark style. Fix #10
1 parent 61cb5e9 commit 57b1441

File tree

4 files changed

+36
-37
lines changed

4 files changed

+36
-37
lines changed

feishu-docx/src/markdown_renderer.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,14 +344,14 @@ export class MarkdownRenderer extends Renderer {
344344
let escape = true;
345345
if (style) {
346346
if (style.bold) {
347-
preWrite = '**';
348-
postWrite = '**';
347+
preWrite = '<b>';
348+
postWrite = '</b>';
349349
} else if (style.italic) {
350-
preWrite = '_';
351-
postWrite = '_';
350+
preWrite = '<em>';
351+
postWrite = '</em>';
352352
} else if (style.strikethrough) {
353-
preWrite = '~~';
354-
postWrite = '~~';
353+
preWrite = '<del>';
354+
postWrite = '</del>';
355355
} else if (style.underline) {
356356
preWrite = '<u>';
357357
postWrite = '</u>';

feishu-docx/tests/fixtures/case0.expect.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535

3636
Feishu2Md 已开源并发布在 Github 中:https://github.com/Wsine/feishu2md
3737

38-
**下载 feishu2md **-** **得益于 golang 本身的多平台编译特性,我已经为 Windows/Linux/Mac 都预编译了该工具的可执行文件,可以直接从 [Github Release](https://github.com/Wsine/feishu2md/releases) 中下载,从压缩包中提取自己平台的 feishu2md 二进制可执行文件即可,建议放置在 PATH 路径中。
38+
<b>下载 feishu2md </b>-<b> </b>得益于 golang 本身的多平台编译特性,我已经为 Windows/Linux/Mac 都预编译了该工具的可执行文件,可以直接从 [Github Release](https://github.com/Wsine/feishu2md/releases) 中下载,从压缩包中提取自己平台的 feishu2md 二进制可执行文件即可,建议放置在 PATH 路径中。
3939

40-
**生成配置文件** - feishu2md 需要使用飞书的 Open API 提取飞书文档,因此需要配置相应的 App ID 和 App Secret 进行 API 的调用。首先,进入飞书的 [开发者后台](https://open.feishu.cn/app) 然后创建一个企业自建应用,信息可以任意填,发布但不必等待审核通过。然后在创建的应用页面中,找到「凭证与基础信息」,即可找到 App ID 和 App Secret 信息。
40+
<b>生成配置文件</b> - feishu2md 需要使用飞书的 Open API 提取飞书文档,因此需要配置相应的 App ID 和 App Secret 进行 API 的调用。首先,进入飞书的 [开发者后台](https://open.feishu.cn/app) 然后创建一个企业自建应用,信息可以任意填,发布但不必等待审核通过。然后在创建的应用页面中,找到「凭证与基础信息」,即可找到 App ID 和 App Secret 信息。
4141

4242
<img src="boxcnh7JKLbFaWhHKHveYzGMNZg" src-width="1168" src-height="555"/>
4343

@@ -51,7 +51,7 @@ Feishu2Md 已开源并发布在 Github 中:https://github.com/Wsine/feishu2md
5151

5252
将 App ID 和 App Secret 填入配置文件 config.json 中的相应位置。另外,image_dir 配置项为存放文档中图片的文件夹名称。
5353

54-
**下载飞书文档** - 通过 `feishu2md 你的飞书文档链接` 直接下载,文档链接可以通过 分享 &gt; 开启链接分享 &gt; 复制链接 获得。
54+
<b>下载飞书文档</b> - 通过 `feishu2md 你的飞书文档链接` 直接下载,文档链接可以通过 分享 &gt; 开启链接分享 &gt; 复制链接 获得。
5555

5656
<img src="boxcnqt9YDTirkKlTATlQI025Ig" src-width="1538" src-height="488"/>
5757

@@ -69,5 +69,4 @@ feishu2md [一日一技:飞书文档转换为 Markdown](doccnrOvzeQ8BSnfsXj8jw
6969

7070
由于 lark_docs_md 是使用 golang 实现的,因此这也是我首次使用 golang 进行开发。对于开发小工具,整体的开发体验非常良好,而且还能编译得到二进制以及享受多平台编译的好处。工具可能还有一些不是很完善的地方,如有问题可以提 issue,我有时间会进行修复的。
7171

72-
最后,欢迎试用,欢迎 PR ~
73-
72+
最后,欢迎试用,欢迎 PR ~

feishu-docx/tests/fixtures/case1.expect.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Overview
66

7-
**Markdown** is created by [Daring Fireball](http://daringfireball.net/); the original guideline is [here](http://daringfireball.net/projects/markdown/syntax). Its syntax, however, varies between different parsers or editors. **Typora** is using [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown/).
7+
<b>Markdown</b> is created by [Daring Fireball](http://daringfireball.net/); the original guideline is [here](http://daringfireball.net/projects/markdown/syntax). Its syntax, however, varies between different parsers or editors. <b>Typora</b> is using [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown/).
88

99
[toc]
1010

@@ -103,13 +103,13 @@ puts markdown.to_html
103103
104104
### Math Blocks
105105
106-
You can render _LaTeX_ mathematical expressions using **MathJax**.
106+
You can render <em>LaTeX</em> mathematical expressions using <b>MathJax</b>.
107107
108-
To add a mathematical expression, input `$$` and press the 'Return' key. This will trigger an input field which accepts _Tex/LaTex_ source. For example:
108+
To add a mathematical expression, input `$$` and press the 'Return' key. This will trigger an input field which accepts <em>Tex/LaTex</em> source. For example:
109109
110110
$$\mathbf{V}_1 \times \mathbf{V}_2 = \begin{vmatrix}\mathbf{i} & \mathbf{j} & \mathbf{k} \\\frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\\frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0 \\\end{vmatrix}$$
111111
112-
In the markdown source file, the math block is a _LaTeX_ expression wrapped by a pair of ‘$$’ marks:
112+
In the markdown source file, the math block is a <em>LaTeX</em> expression wrapped by a pair of ‘$$’ marks:
113113
114114
```md
115115
$$
@@ -208,7 +208,7 @@ This is [an example](http://example.com/) inline link. (`<p>This is <a href="htt
208208

209209
#### Internal Links
210210

211-
**You can set the href to headers**, which will create a bookmark that allow you to jump to that section after clicking. For example:
211+
<b>You can set the href to headers</b>, which will create a bookmark that allow you to jump to that section after clicking. For example:
212212

213213
Command(on Windows: Ctrl) + Click This link will jump to header `Block Elements`. To see how to write that, please move cursor or click that link with `` key pressed to expand the element into markdown source.
214214

@@ -275,9 +275,9 @@ _single underscores_
275275

276276
output:
277277

278-
_single asterisks_
278+
<em>single asterisks</em>
279279

280-
_single underscores_
280+
<em>single underscores</em>
281281

282282
GFM will ignore underscores in words, which is commonly used in code and names, like this:
283283

@@ -305,9 +305,9 @@ __double underscores__
305305

306306
output:
307307

308-
**double asterisks**
308+
<b>double asterisks</b>
309309

310-
**double underscores**
310+
<b>double underscores</b>
311311

312312
Typora recommends using the `**` symbol.
313313

@@ -327,7 +327,7 @@ Use the `printf()` function.
327327

328328
GFM adds syntax to create strikethrough text, which is missing from standard Markdown.
329329

330-
`~~Mistaken text.~~` becomes ~~Mistaken text.~~
330+
`~~Mistaken text.~~` becomes <del>Mistaken text.</del>
331331

332332
### Underlines
333333

feishu-docx/tests/fixtures/case3.expect.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717
</div>
1818
</div>
1919

20-
导出**飞书知识库**,并按相同目录结构生成 [Static Page Generator](https://www.google.com/search?q=Static+Page+Generator) 支持 Markdown 文件组织方式,用于发布为静态网站。
20+
导出<b>飞书知识库</b>,并按相同目录结构生成 [Static Page Generator](https://www.google.com/search?q=Static+Page+Generator) 支持 Markdown 文件组织方式,用于发布为静态网站。
2121

2222
内容格式支持:[Content Examples](Ks7jwPEtJiyUXckawcRcJ68jnvg) [直接连接](https://longbridge.feishu.cn/wiki/Ks7jwPEtJiyUXckawcRcJ68jnvg)
2323

24-
## **Features**
24+
## <b>Features</b>
2525

26-
- [feishu-docx](https://github.com/longbridgeapp/feishu-pages/tree/main/feishu-docx) - 支持将飞书新版文档 Docx 转换为 Markdown 或其他格式(_目前只支持 Markdown_
26+
- [feishu-docx](https://github.com/longbridgeapp/feishu-pages/tree/main/feishu-docx) - 支持将飞书新版文档 Docx 转换为 Markdown 或其他格式(<em>目前只支持 Markdown</em>
2727
- 目录结构组织
2828
- 图片下载
2929
- 与 GitHub Actions 结合
3030
- 生成支持 [Docusaurus](https://docusaurus.io/) 支持的 Markdown 格式,以实现目录结构组织(基于 `sidebar_position`
3131

32-
## **Installation**
32+
## <b>Installation</b>
3333

3434
Feishu Pages 可以以 Npm 的方式引入到 Static Page Generator 的项目中。
3535

@@ -44,13 +44,13 @@ yarn add feishu-pages
4444

4545
[test-file.zip](TVEyb1pmWo8oIwxyL3kcIfrrnGd)
4646

47-
## **Feishu Permissions**
47+
## <b>Feishu Permissions</b>
4848

4949
- `docx:document:readonly`
5050
- `wiki:wiki:readonly`
5151
- `drive:drive:readonly`
5252

53-
## **Configuration**
53+
## <b>Configuration</b>
5454

5555
<table header_column="1" header_row="1">
5656
<colgroup>
@@ -60,7 +60,7 @@ yarn add feishu-pages
6060
<col width="405"/>
6161
</colgroup>
6262
<thead>
63-
<tr><th><p><strong>名称</strong></p></th><th><p>Description</p></th><th><p>Required</p></th><th><p>Default</p></th></tr>
63+
<tr><th><p><b>名</b><b>称</b></p></th><th><p>Description</p></th><th><p>Required</p></th><th><p>Default</p></th></tr>
6464
</thead>
6565
<tbody>
6666
<tr><td><p>FEISHU_APP_ID</p></td><td><p>飞书应用 ID</p></td><td><p>YES</p></td><td></td></tr>
@@ -72,9 +72,9 @@ yarn add feishu-pages
7272
</tbody>
7373
</table>
7474

75-
## **Usage**
75+
## <b>Usage</b>
7676

77-
### **创建飞书应用并开通权限**
77+
### <b>创建飞书应用并开通权限</b>
7878

7979
1. 请访问 [https://open.feishu.cn/app](https://open.feishu.cn/app) 创建一个新应用,并获得:
8080
- `App ID`
@@ -93,21 +93,21 @@ yarn add feishu-pages
9393
5. 在飞书 IM 中创建新群 `Feishu Pages`,将应用添加为该群机器人,知识库管理员在「知识空间设置」-&gt; 「权限设置」-&gt;「添加管理员」中添加,把这个 `Feishu Pages` 群加成 <b>管理员:</b>。
9494
- 否则会遇到 `permission denied: wiki space permission denied` 错误。 [ref](https://open.feishu.cn/document/server-docs/docs/wiki-v2/wiki-qa)
9595

96-
### **获取飞书知识库 space_id**
96+
### <b>获取飞书知识库 </b><b>space_id</b>
9797

9898
我们需要配置 `FEISHU_SPACE_ID` 的环境变量,这个为飞书知识库的 `space_id`,你可以访问知识库设置界面,从 URL 中获取。
9999

100100
例如:`https://your-company.feishu.cn/wiki/settings/6992046856314306562` 这里面 `6992046856314306562``space_id`
101101

102-
### **环境变量配置**
102+
### <b>环境变量配置</b>
103103

104104
Feishu Pages 支持 `.env` 文件,如果执行的根目录有个 `.env` 文件,将会自动读取。
105105

106106
> 请参考 `.env.default` 配置环境变量。
107107
108108
如需在 GitHub Actions 的 CI 流程里面使用,建议添加到 Secrets 中,再通过环境变量的方式获取。
109109

110-
## **从知识库导出 Markdown 文档**
110+
## <b>从知识库导出 Markdown 文档</b>
111111

112112
```bash
113113
cd your-project/
@@ -116,9 +116,9 @@ yarn feishu-pages
116116

117117
按上面默认的配置,最终会在 `./dist` 目录下生成 Markdown 文件以及导出的图片文件,如果你期望调整目录,可以自己设置 `OUTPUT_DIR` 环境变量。
118118

119-
## **常见问题**
119+
## <b>常见问题</b>
120120

121-
### **Rate Limit 相关错误**
121+
### <b>Rate Limit 相关错误</b>
122122

123123
> Error: request trigger frequency limit
124124
@@ -167,6 +167,6 @@ yarn feishu-pages
167167
</tbody>
168168
</table>
169169
170-
## **License**
170+
## <b>License</b>
171171
172-
MIT
172+
MIT

0 commit comments

Comments
 (0)