@@ -28,6 +28,9 @@ class Md2Docx
2828 static string e_kew = "" ;
2929 static string endnote = "" ;
3030 static string filename = "" ;
31+ static string mdPath = "input.md" ;
32+ static string filePath = "" ;
33+ static string configPath = "config.json" ;
3134
3235 private static void Usage ( )
3336 {
@@ -40,9 +43,6 @@ private static void Usage()
4043
4144 private static void Main ( string [ ] args )
4245 {
43- string mdPath = "input.md" ;
44- string filePath = "" ;
45- string configPath = "config.json" ;
4646
4747 if ( args . Length < 2 )
4848 {
@@ -66,33 +66,7 @@ private static void Main(string[] args)
6666 {
6767 if ( element is YamlHeaderBlock yaml )
6868 {
69- name = yaml . Children [ "name" ] ;
70- id = yaml . Children [ "id" ] ;
71- teacher = yaml . Children [ "teacher" ] ;
72- department = yaml . Children [ "department" ] ;
73- filename = yaml . Children [ "filename" ] ;
74- clas = yaml . Children [ "class" ] ;
75- if ( filePath == "" )
76- {
77- filePath = id + name + filename + ".docx" ;
78- }
79-
80- if ( yaml . Children . ContainsKey ( "e_abs" ) )
81- {
82- c_abs = yaml . Children [ "c_abs" ] ;
83- c_kew = yaml . Children [ "c_kew" ] ;
84- c_title = yaml . Children [ "c_title" ] ;
85- }
86- if ( yaml . Children . ContainsKey ( "e_abs" ) )
87- {
88- e_abs = yaml . Children [ "e_abs" ] ;
89- e_kew = yaml . Children [ "e_kew" ] ;
90- e_title = yaml . Children [ "e_title" ] ;
91- }
92- if ( yaml . Children . ContainsKey ( "end" ) )
93- {
94- endnote = yaml . Children [ "end" ] ;
95- }
69+ ParseYAMLHeader ( yaml ) ;
9670 }
9771 }
9872
@@ -111,18 +85,50 @@ private static void Main(string[] args)
11185 }
11286 }
11387
88+ private static void ParseYAMLHeader ( YamlHeaderBlock yaml )
89+ {
90+ name = yaml . Children [ "name" ] ;
91+ id = yaml . Children [ "id" ] ;
92+ teacher = yaml . Children [ "teacher" ] ;
93+ department = yaml . Children [ "department" ] ;
94+ filename = yaml . Children [ "filename" ] ;
95+ clas = yaml . Children [ "class" ] ;
96+ if ( filePath == "" )
97+ {
98+ filePath = id + name + filename + ".docx" ;
99+ }
100+
101+ if ( yaml . Children . ContainsKey ( "e_abs" ) )
102+ {
103+ c_abs = yaml . Children [ "c_abs" ] ;
104+ c_kew = yaml . Children [ "c_kew" ] ;
105+ c_title = yaml . Children [ "c_title" ] ;
106+ }
107+ if ( yaml . Children . ContainsKey ( "e_abs" ) )
108+ {
109+ e_abs = yaml . Children [ "e_abs" ] ;
110+ e_kew = yaml . Children [ "e_kew" ] ;
111+ e_title = yaml . Children [ "e_title" ] ;
112+ }
113+ if ( yaml . Children . ContainsKey ( "end" ) )
114+ {
115+ endnote = yaml . Children [ "end" ] ;
116+ }
117+ }
118+
114119 // Generates content of mainDocumentPart1.
115120 private static void GenerateMainDocumentPart1Content ( MainDocumentPart mainDocumentPart1 , MarkdownDocument document , JObject correspondecs , JObject optionalParts )
116121 {
117122 Document document1 = new Document ( ) { MCAttributes = new MarkupCompatibilityAttributes ( ) } ;
118123
119124 Body docBody = new Body ( ) ;
120125
121- bool genEnd = false ;
122-
123- ImagePart imagePart1 = mainDocumentPart1 . AddNewPart < ImagePart > ( "image/jpeg" , "rId8" ) ;
124- GenerateImagePart1Content ( imagePart1 ) ;
125- GenerateCover ( ref docBody ) ;
126+ if ( ( bool ) optionalParts [ "封面" ] )
127+ {
128+ ImagePart imagePart1 = mainDocumentPart1 . AddNewPart < ImagePart > ( "image/jpeg" , "rId8" ) ;
129+ GenerateImagePart1Content ( imagePart1 ) ;
130+ GenerateCover ( ref docBody ) ;
131+ }
126132
127133 if ( c_title != "" )
128134 {
@@ -1562,7 +1568,7 @@ private static void Add_abstract(string title, string abs, string keyWords, bool
15621568 {
15631569 ParagraphProperties = new ParagraphProperties
15641570 {
1565- ParagraphStyleId = new ParagraphStyleId ( ) { Val = "Abstract" }
1571+ ParagraphStyleId = new ParagraphStyleId ( ) { Val = "Abstract Title " }
15661572 }
15671573 } ;
15681574 Run run = new Run { RunProperties = new RunProperties ( ) } ;
@@ -1581,7 +1587,7 @@ private static void Add_abstract(string title, string abs, string keyWords, bool
15811587 {
15821588 ParagraphProperties = new ParagraphProperties
15831589 {
1584- ParagraphStyleId = new ParagraphStyleId { Val = "Abs " }
1590+ ParagraphStyleId = new ParagraphStyleId { Val = "Abstract Subtitle " }
15851591 }
15861592 } ;
15871593 run = new Run
0 commit comments