From 603c5032c3c346d4ee8661648e2853d087860b6b Mon Sep 17 00:00:00 2001
From: Dnomd343
Date: Thu, 29 Dec 2022 21:46:50 +0800
Subject: [PATCH] feat: to html format
---
src/release/to_html.py | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
create mode 100644 src/release/to_html.py
diff --git a/src/release/to_html.py b/src/release/to_html.py
new file mode 100644
index 0000000..89f5fbc
--- /dev/null
+++ b/src/release/to_html.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import sys
+from common import loadData
+
+
+def formatMetadata(metadata: dict) -> str:
+ return '栩栩若生
\n' + '\n'.join(
+ ['
%s
' % x for x in metadata['desc']] + ) + + +def formatChapter(caption: str, content: list) -> str: + return '%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) + ) + return '\n\n'.join(result) + + +if __name__ == '__main__': + data = loadData(sys.argv[1]) + print(htmlRelease(data['metadata'], data['content']))