fix: support utf-8

This commit is contained in:
starnakin 2024-08-06 12:56:44 +02:00
parent 65a2adafab
commit e1d4e4f683
2 changed files with 12 additions and 2 deletions

View File

@ -2,6 +2,7 @@
<head> <head>
<title>My Readings</title> <title>My Readings</title>
<meta charset="UTF-8">
<style> <style>
{{style}} {{style}}
</style> </style>

13
main.py
View File

@ -1,6 +1,8 @@
import json import json
import sys
from Book import Book from Book import Book
# Opening JSON file # Opening JSON file
f = open('constructor.json', encoding='utf-8') f = open('constructor.json', encoding='utf-8')
data = json.load(f) data = json.load(f)
@ -17,5 +19,12 @@ for book_data in books:
html += book.to_html() html += book.to_html()
f = open("cast.html") f = open("cast.html")
print(f.read().replace("{{books}}", html).replace("{{style}}", style)) text = f.read().replace("{{books}}", html).replace("{{style}}", style)
f.close() f.close()
if len(sys.argv) > 1:
f = open(sys.argv[1], "w", encoding='utf-8')
f.write(text)
f.close()
else:
print(text)