Skip to content

Commit fac03fd

Browse files
author
Roman Elokhin (Europe)
committed
-
1 parent d59ef84 commit fac03fd

14 files changed

+528
-7
lines changed

README.md

+20-7
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,29 @@ Was tested for Windows 10.
8080
- install Python3 with YAML and pywin32 packages (win32com.client)
8181
- install Pandoc
8282
- install any MarkDown editor. I use Typora. Any simple text editor can be used, but this is not very convenient
83-
84-
## Files
85-
- <a href="https://github.com/nihole/md2docx/blob/master/render.py">render.py</a> - Python script. Takes data from the markdown file, converts and inserts it into a Word document
86-
- <a href="https://github.com/nihole/md2docx/blob/master/structure.yml">structure.yml</a> - YAML file with all the necessary parameters for render.py
83+
- copy folder 'example' to your local git repository. Change the name of the folder in accordance with your project. Now you can use this folder for new documentation creation
84+
- change mkword.py file:
85+
- change the path to the script/render.py file
86+
- you may change the path to ./structure.yml
87+
- change or create appropriate Word template file
88+
- change in accordance with your documentation structure.yml file
89+
- create MarkDown file
90+
- execute python3 mkword.py
91+
- new Word file will be created from your MarkDown file
92+
- now you can use git for documentation creation
93+
94+
## Files in Example
95+
- <a href="https://github.com/nihole/md2docx/blob/master/render.py">render.py</a> - Python script. Takes data from the markdown file, converts and inserts it into a Word document. This is a static file. You usually don't need to change it. You even don't need to copy this file to your local git repository but you need to add the path to this file into mkword.py file
96+
- <a href="https://github.com/nihole/md2docx/blob/master/structure.yml">structure.yml</a> - YAML file with all the necessary parameters for render.py. Normally you adjust this file only once at the beginning. You have to add the path to this file into the mkword.py file
97+
- folder templates - folder with Word templates
8798
- template.docx is a Word document that we are going to fill out with the context of markdown documents. This Word document should have all the styles, templates ... you are going to use. This document is divided manually into sections. Each section corresponds to one chapter
88-
- <a href="https://github.com/nihole/md2docx/blob/master/example_chapter.md">example_chapter.md</a> - markdown document with example information
89-
- <a href="https://github.com/nihole/md2docx/tree/master/initial">initial folder</a> - initial files
99+
- folder media - folder with pictures
100+
- <a href="https://github.com/nihole/md2docx/blob/master/example_chapter.md">example_chapter.md</a> - markdown document with example information. Of course, for your documentation, the name will differ. You have to add the path to this file into mkword.py file
101+
- mkword.py - python script with the references to render.py and structure.yml files.
90102

91103
## How to start
92-
- python3 render.py
104+
- cd example
105+
- python3 mkword.py
93106
- yes
94107
- yes
95108

example/example_chapter.md

+248
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
# Example Chapter
2+
3+
4+
5+
## h2 Heading
6+
7+
### h3 Heading
8+
#### h4 Heading
9+
##### h5 Heading
10+
###### h6 Heading
11+
12+
13+
## Horizontal Rules
14+
15+
___
16+
17+
---
18+
19+
***
20+
21+
22+
## Typographic replacements
23+
24+
Enable typographer option to see result.
25+
26+
(c) (C) (r) (R) (tm) (TM) (p) (P) +-
27+
28+
test.. test... test..... test?..... test!....
29+
30+
!!!!!! ???? ,, -- ---
31+
32+
"Smartypants, double quotes" and 'single quotes'
33+
34+
35+
## Emphasis
36+
37+
**This is bold text**
38+
39+
__This is bold text__
40+
41+
*This is italic text*
42+
43+
_This is italic text_
44+
45+
~~Strikethrough~~
46+
47+
48+
## Blockquotes
49+
50+
51+
> Blockquotes can also be nested...
52+
> > ...by using additional greater-than signs right next to each other...
53+
> >
54+
> > > ...or with spaces between arrows.
55+
56+
57+
## Lists
58+
59+
Unordered
60+
61+
+ Create a list by starting a line with `+`, `-`, or `*`
62+
+ Sub-lists are made by indenting 2 spaces:
63+
- Marker character change forces new list start:
64+
* Ac tristique libero volutpat at
65+
+ Facilisis in pretium nisl aliquet
66+
- Nulla volutpat aliquam velit
67+
+ Very easy!
68+
69+
Ordered
70+
71+
1. Lorem ipsum dolor sit amet
72+
2. Consectetur adipiscing elit
73+
3. Integer molestie lorem at massa
74+
75+
76+
1. You can use sequential numbers...
77+
1. ...or keep all the numbers as `1.`
78+
79+
Start numbering with offset:
80+
81+
57. foo
82+
1. bar
83+
84+
85+
## Code
86+
87+
Inline `code`
88+
89+
Indented code
90+
91+
// Some comments
92+
line 1 of code
93+
line 2 of code
94+
line 3 of code
95+
96+
97+
Block code "fences"
98+
99+
```
100+
Sample text here...
101+
```
102+
103+
Syntax highlighting
104+
105+
``` js
106+
var foo = function (bar) {
107+
return bar++;
108+
};
109+
110+
console.log(foo(5));
111+
```
112+
113+
## Tables
114+
115+
Table: Left aligned columns
116+
| Option | Description |
117+
| ------ | ----------- |
118+
| data | path to data files to supply the data that will be passed into templates. |
119+
| engine | engine to be used for processing templates. Handlebars is the default. |
120+
| ext | extension to be used for dest files. |
121+
122+
123+
Table: Right aligned columns
124+
| Option | Description |
125+
| ------:| -----------:|
126+
| data | path to data files to supply the data that will be passed into templates. |
127+
| engine | engine to be used for processing templates. Handlebars is the default. |
128+
| ext | extension to be used for dest files. |
129+
130+
131+
## Links
132+
133+
[link text](http://dev.nodeca.com)
134+
135+
[link with title](http://nodeca.github.io/pica/demo/ "title text!")
136+
137+
Autoconverted link https://github.com/nodeca/pica (enable linkify to see)
138+
139+
140+
## Images
141+
142+
![Minion](media/minion.png)
143+
Figure: Minion
144+
145+
!["Stormtroopocat"](media/stormtroopocat.jpg)
146+
Figure: Stormtroopocat
147+
148+
149+
## Plugins
150+
151+
The killer feature of `markdown-it` is very effective support of
152+
[syntax plugins](https://www.npmjs.org/browse/keyword/markdown-it-plugin).
153+
154+
155+
### [Emojies](https://github.com/markdown-it/markdown-it-emoji)
156+
157+
> Classic markup: :wink: :crush: :cry: :tear: :laughing: :yum:
158+
>
159+
> Shortcuts (emoticons): :-) :-( 8-) ;)
160+
161+
see [how to change output](https://github.com/markdown-it/markdown-it-emoji#change-output) with twemoji.
162+
163+
164+
### [Subscript](https://github.com/markdown-it/markdown-it-sub) / [Superscript](https://github.com/markdown-it/markdown-it-sup)
165+
166+
- 19^th^
167+
- H~2~O
168+
169+
170+
### [\<ins>](https://github.com/markdown-it/markdown-it-ins)
171+
172+
++Inserted text++
173+
174+
175+
### [\<mark>](https://github.com/markdown-it/markdown-it-mark)
176+
177+
==Marked text==
178+
179+
180+
### [Footnotes](https://github.com/markdown-it/markdown-it-footnote)
181+
182+
Footnote 1 link[^first].
183+
184+
Footnote 2 link[^second].
185+
186+
Inline footnote^[Text of inline footnote] definition.
187+
188+
Duplicated footnote reference[^second].
189+
190+
[^first]: Footnote **can have markup**
191+
192+
and multiple paragraphs.
193+
194+
[^second]: Footnote text.
195+
196+
197+
### [Definition lists](https://github.com/markdown-it/markdown-it-deflist)
198+
199+
Term 1
200+
201+
: Definition 1
202+
with lazy continuation.
203+
204+
Term 2 with *inline markup*
205+
206+
: Definition 2
207+
208+
{ some code, part of Definition 2 }
209+
210+
Third paragraph of definition 2.
211+
212+
_Compact style:_
213+
214+
Term 1
215+
~ Definition 1
216+
217+
Term 2
218+
~ Definition 2a
219+
~ Definition 2b
220+
221+
222+
### [Abbreviations](https://github.com/markdown-it/markdown-it-abbr)
223+
224+
This is HTML abbreviation example.
225+
226+
It converts "HTML", but keep intact partial entries like "xxxHTMLyyy" and so on.
227+
228+
*[HTML]: Hyper Text Markup Language
229+
230+
### [Custom containers](https://github.com/markdown-it/markdown-it-container)
231+
232+
::: warning
233+
*here be dragons*
234+
:::
235+
236+
### Anchors
237+
238+
[this is a link](#anchor)
239+
240+
[this is anchor]{#anchor}
241+
242+
Comments:
243+
244+
<!-- This is commented out. -->
245+
[comment]:
246+
247+
248+

example/media/dojocat.jpg

66.1 KB
Loading

example/media/md2word_work_flow.png

116 KB
Loading

example/media/minion.png

91.3 KB
Loading
2.59 MB
Loading

example/media/stormtroopocat.jpg

93.7 KB
Loading

example/mkword.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import os
2+
import sys
3+
4+
render_path = '../scripts/render.py'
5+
6+
structure_path = './structure.yml'
7+
8+
######### Main Body ######################
9+
10+
11+
######### get file's names from the command line ####################
12+
if not (len(sys.argv)==1):
13+
print (" ######################################################\n")
14+
print (" Syntax is:\n")
15+
print (" python3 mkword.py\n")
16+
print (" Change paths in mkword.py if needed.\n")
17+
print (" ######################################################\n")
18+
quit()
19+
20+
cmd = 'python %s %s' % (render_path, structure_path)
21+
22+
returned_value = os.system(cmd)
23+

example/structure.yml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# visible, save, close: yes/no, change script behaviour
2+
# structure_verification: yes/no, verify if the 1st header in the section is correct
3+
# change_data: yes/no, replace or not data inside the section with the data received from md file
4+
# table_style: yes/no, change or not the table style in this section
5+
# table_caption: yes/no, insert or not captions for the tables in this section based of the caption in the md file
6+
# figure_caption: yes/no, insert or not captions for the figures in this section based of the caption in the md file
7+
# update_fields: yes/no, update or not fields for whole word document
8+
9+
10+
script:
11+
word:
12+
visible: True
13+
save: "no"
14+
close: "no"
15+
actions:
16+
structure_verification: "yes"
17+
change_data: "yes"
18+
table_style: "yes"
19+
table_caption: "yes"
20+
figure_caption: "yes"
21+
update_fields: "yes"
22+
23+
24+
# table_style: table style
25+
# dest_word_file: path ot the word (docx) document
26+
27+
general:
28+
table_style: "AS Table"
29+
dest_word_file: "templates/template.docx"
30+
31+
#
32+
# Manually split the word document into sections.
33+
#
34+
# number: the number of the section (1,2,...)
35+
# name: the first title in the section. Scipt verifies if this title is really the first title if the section with the number above.
36+
# md_file: the path to the md file fom which you are going to take data
37+
# action: if "ignore" then will be ignored
38+
#
39+
40+
sections:
41+
- number: 4
42+
name: "Chapter 1"
43+
description: ""
44+
md_file: ""
45+
action: "ignore"
46+
- number: 5
47+
name: "Chapter 2"
48+
description: ""
49+
md_file: ""
50+
action: "ignore"
51+
- number: 6
52+
name: "Chapter 3"
53+
description: ""
54+
md_file: ""
55+
action: "ignore"
56+
- number: 7
57+
name: "Example Chapter"
58+
description: ""
59+
md_file: "example_chapter.md"
60+
action: ""
61+
- number: 8
62+
name: "Chapter 100"
63+
description: ""
64+
md_file: ""
65+
action: "ignore"

example/templates/template.docx

449 KB
Binary file not shown.

example/templates/~$mplate.docx

162 Bytes
Binary file not shown.

example/tmp/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
for tmp word files
2+

example/tmp/tmp_word.docx

195 KB
Binary file not shown.

0 commit comments

Comments
 (0)