Skip to content
This repository was archived by the owner on May 21, 2022. It is now read-only.

Commit e6349bd

Browse files
committed
refactor: rename function as same style
1 parent 020c718 commit e6349bd

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,20 @@
2828

2929
[specification](./docs/spec.md)
3030

31-
## 文档
31+
## 配置文件
32+
33+
schema文件为[schema](./docs/schema.json),示例文件为[default config](./examples/config.json)
3234

33-
TBD
35+
## 文档
3436

3537
在我的[博客](https://csuwangj.github.io/%E7%BC%96%E7%A8%8B%E6%98%AF%E5%BE%88%E5%A5%BD%E7%8E%A9%E7%9A%84-md2docx%E6%98%AF%E6%80%8E%E4%B9%88%E5%86%99%E5%87%BA%E6%9D%A5%E7%9A%84/)中对写这个程序的过程做了一个简介,同时总结了一下用到的资料,暂且先用它吧。
3638

3739
## TODO
3840

3941
- [x] 加入测试(并重构)
42+
- [x] 将格式等设置改为配置文件而非硬编码
4043
- [ ] 部署CI
4144
- [ ] 将parser更换成一个标准更接近GFM的parser
42-
- [x] 将格式等设置改为配置文件而非硬编码
4345
- [ ] 页眉
4446
- [ ] 页脚
4547
- [ ] 图片

docs/spec.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,22 @@ d|e|f
174174
175175
### 结束语
176176
177-
放在yaml头部的end键中,同样的,不要有换行。
177+
使用一级标题+正文的组合
178178
179179
### 参考文献
180180
181-
在文章末尾使用引用格式放出,例子如下
181+
在文章末尾使用一级标题+引用格式的组合放出,例子如下
182182
183-
```
183+
```markdown
184184
> [1] 王阳. 第三人称叙事的形式叙述者的限定[J]. 四川外语学院学报,2000(1):1-6.
185185
>
186186
> [2] HAIMAN J. The Iconicity of Grammar[J]. Language,1980(56):515-540.
187187
>
188188
> [3] 陈牧. 拓扑绝缘体薄膜表面态和掺杂效应的STM研究[D]. 清华大学,2012.
189189
```
190+
191+
> [1] 王阳. 第三人称叙事的形式叙述者的限定[J]. 四川外语学院学报,2000(1):1-6.
192+
>
193+
> [2] HAIMAN J. The Iconicity of Grammar[J]. Language,1980(56):515-540.
194+
>
195+
> [3] 陈牧. 拓扑绝缘体薄膜表面态和掺杂效应的STM研究[D]. 清华大学,2012.

examples/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "./test.json",
2+
"$schema": "./config.json",
33

44
"样式": [
55
{

md2docx/md2docx.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ private static void GenerateMainDocumentPart1Content(MainDocumentPart mainDocume
105105

106106
if ((bool)optionalParts["摘要"] && info.ContainsKey("c_title"))
107107
{
108-
Add_abstract(info["c_title"], info["c_abs"], info["c_kew"], true, ref docBody);
108+
AddAbstract(info["c_title"], info["c_abs"], info["c_kew"], true, ref docBody);
109109
}
110110

111111
if ((bool)optionalParts["摘要"] && info.ContainsKey("e_title"))
112112
{
113-
Add_abstract(info["e_title"], info["e_abs"], info["e_kew"], false, ref docBody);
113+
AddAbstract(info["e_title"], info["e_abs"], info["e_kew"], false, ref docBody);
114114
}
115115

116116
GeneratedCode.GenerateTOC(ref docBody);
@@ -127,7 +127,7 @@ private static void GenerateMainDocumentPart1Content(MainDocumentPart mainDocume
127127
ParagraphStyleId = new ParagraphStyleId { Val = "bodytext" }
128128
}
129129
};
130-
Deal_md_inline(new RunProperties(), mpara.Inlines, ref docPara);
130+
DealMDInlines(new RunProperties(), mpara.Inlines, ref docPara);
131131
docBody.Append(docPara);
132132
}else if (element is HeaderBlock mhead)
133133
{
@@ -140,14 +140,14 @@ private static void GenerateMainDocumentPart1Content(MainDocumentPart mainDocume
140140
default:
141141
throw new Exception($"Rendering {element.GetType()} not implement yet");
142142
}
143-
Deal_md_inline(new RunProperties(), mhead.Inlines, ref docPara);
143+
DealMDInlines(new RunProperties(), mhead.Inlines, ref docPara);
144144
docBody.Append(docPara);
145145
}
146146
else if (element is QuoteBlock refer)
147147
{
148148
foreach (var e in refer.Blocks)
149149
{
150-
Deal_quote_refer(e, ref docBody);
150+
DealQuoteRefer(e, ref docBody);
151151
}
152152
}
153153
else if(!(element is YamlHeaderBlock))
@@ -191,7 +191,7 @@ private static void GenerateCoverImage(ImagePart imagePart1)
191191
/// <param name="rp">Current Run Properties, because special style may be nesting so we need keep it</param>
192192
/// <param name="inline">Current Inline element</param>
193193
/// <param name="docPara">In which we append out text</param>
194-
private static void Deal_md_inline(RunProperties rp, IList<MarkdownInline> inlines, ref Paragraph docPara)
194+
private static void DealMDInlines(RunProperties rp, IList<MarkdownInline> inlines, ref Paragraph docPara)
195195
{
196196
foreach(MarkdownInline inline in inlines)
197197
{
@@ -219,28 +219,28 @@ private static void Deal_md_inline(RunProperties rp, IList<MarkdownInline> inlin
219219
RunProperties newbrp = (RunProperties)rp.Clone();
220220
newbrp.Bold = new Bold();
221221
newbrp.BoldComplexScript = new BoldComplexScript();
222-
Deal_md_inline(newbrp, bd.Inlines, ref docPara);
222+
DealMDInlines(newbrp, bd.Inlines, ref docPara);
223223
break;
224224
case ItalicTextInline it:
225225
RunProperties newirp = (RunProperties)rp.Clone();
226226
newirp.Italic = new Italic();
227227
newirp.ItalicComplexScript = new ItalicComplexScript();
228-
Deal_md_inline(newirp, it.Inlines, ref docPara);
228+
DealMDInlines(newirp, it.Inlines, ref docPara);
229229
break;
230230
case StrikethroughTextInline st:
231231
RunProperties newstrp = (RunProperties)rp.Clone();
232232
newstrp.Strike = new Strike();
233-
Deal_md_inline(newstrp, st.Inlines, ref docPara);
233+
DealMDInlines(newstrp, st.Inlines, ref docPara);
234234
break;
235235
case SubscriptTextInline sb:
236236
RunProperties newsbrp = (RunProperties)rp.Clone();
237237
newsbrp.VerticalTextAlignment = new VerticalTextAlignment() { Val = VerticalPositionValues.Subscript };
238-
Deal_md_inline(newsbrp, sb.Inlines, ref docPara);
238+
DealMDInlines(newsbrp, sb.Inlines, ref docPara);
239239
break;
240240
case SuperscriptTextInline sp:
241241
RunProperties newsprp = (RunProperties)rp.Clone();
242242
newsprp.VerticalTextAlignment = new VerticalTextAlignment() { Val = VerticalPositionValues.Superscript };
243-
Deal_md_inline(newsprp, sp.Inlines, ref docPara);
243+
DealMDInlines(newsprp, sp.Inlines, ref docPara);
244244
break;
245245
default:
246246
Console.WriteLine(inline.ToString());
@@ -254,7 +254,7 @@ private static void Deal_md_inline(RunProperties rp, IList<MarkdownInline> inlin
254254
/// </summary>
255255
/// <param name="block">Paragraph block, when block is not paragraph block, it throw a exception</param>
256256
/// <param name="docBody">In which we append our text</param>
257-
private static void Deal_quote_refer(MarkdownBlock block, ref Body docBody)
257+
private static void DealQuoteRefer(MarkdownBlock block, ref Body docBody)
258258
{
259259
if (!(block is ParagraphBlock))
260260
{
@@ -289,7 +289,7 @@ private static void Deal_quote_refer(MarkdownBlock block, ref Body docBody)
289289
/// <param name="keyWords">Key words</param>
290290
/// <param name="isCN">If it's Chinese abstract</param>
291291
/// <param name="docBody">In which we append our text</param>
292-
private static void Add_abstract(string title, string abs, string keyWords, bool isCN, ref Body docBody)
292+
private static void AddAbstract(string title, string abs, string keyWords, bool isCN, ref Body docBody)
293293
{
294294
string subtitle = isCN ? "摘要" : "ABSTRACT";
295295
string keyWT = isCN ? "关键词:" : "Key words: ";

0 commit comments

Comments
 (0)