-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
29 lines (20 loc) · 836 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import json
class Converter:
def __init__(self, file):
self.file = file
def convert_json_to_md(self):
with open(self.file) as file:
file = json.load(file)
print(file)
# loop over file
for book in file['documents']:
# Create a new md file
with open(f'{book["title"]}.md', 'a') as markdown_file:
markdown_file.write(f'# {book["title"]} \n')
# Loop entries
for entry in book['entries']:
markdown_file.write(f'## {entry["chapter"]} \n')
markdown_file.write('>[!quote] (Enter) >\n')
markdown_file.write(f'> {entry["text"]} \n')
converter = Converter('wyciag.json')
converter.convert_json_to_md()