-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
58 lines (41 loc) · 1.24 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#Software By AwesomeWithRex
def read_file(filename):
with open(filename) as f:
filename = f.readlines()
return filename
def get_template():
template = ''
with open('template.html', 'r') as f:
template = f.readlines()
return template
def put_in_body(file, template):
count = 0
body_tag = 0
for i in template:
count += 1
if '|b|' in i:
body_tag = count - 1
text_to_append = ""
for line in file:
text_to_append += line
formatted_text = ""
for word in text_to_append:
formatted_text += word
if '\n' in word:
formatted_text += word.replace('\n', '<br/>\t')
template[body_tag] = template[body_tag].replace('|b|', formatted_text)
for i in template:
print(i)
return template
def save_template(name_of_doc, saved_doc_file):
with open(name_of_doc, 'w') as f:
f.writelines(saved_doc_file)
def put_in_title():
pass
def main():
content = read_file('text.txt')
template = get_template()
formatted_template = put_in_body(content, template)
save_template('the.html',formatted_template)
if __name__=='__main__':
main()