From 6246d23bf379e8e8f6b47a04d20b111a9d343464 Mon Sep 17 00:00:00 2001
From: Dnomd343
Date: Thu, 29 Dec 2022 22:11:23 +0800
Subject: [PATCH] update: html format for calibre
---
src/release/{to_html.py => calibre_html.py} | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
rename src/release/{to_html.py => calibre_html.py} (63%)
mode change 100644 => 100755
diff --git a/src/release/to_html.py b/src/release/calibre_html.py
old mode 100644
new mode 100755
similarity index 63%
rename from src/release/to_html.py
rename to src/release/calibre_html.py
index 89f5fbc..6fea4a1
--- a/src/release/to_html.py
+++ b/src/release/calibre_html.py
@@ -3,6 +3,9 @@
import sys
from common import loadData
+from common import saveFile
+
+htmlFile = 'xxrs.html'
def formatMetadata(metadata: dict) -> str:
@@ -11,19 +14,15 @@ def formatMetadata(metadata: dict) -> str:
)
-def formatChapter(caption: str, content: list) -> str:
- return '%s
\n' % caption + '\n'.join(['
%s
' % x for x in content]) - - def htmlRelease(metadata: dict, content: dict) -> str: result = [formatMetadata(metadata)] for (title, chapter) in content.items(): result.append( - formatChapter(title, chapter) + '%s
' % x for x in chapter]) ) - return '\n\n'.join(result) + return '\n\n'.join(result) + '\n' if __name__ == '__main__': data = loadData(sys.argv[1]) - print(htmlRelease(data['metadata'], data['content'])) + saveFile(htmlFile, htmlRelease(data['metadata'], data['content']))