Browse Source

update: html format for calibre

master
Dnomd343 2 years ago
parent
commit
6246d23bf3
  1. 13
      src/release/calibre_html.py

13
src/release/to_html.py → src/release/calibre_html.py

@ -3,6 +3,9 @@
import sys import sys
from common import loadData from common import loadData
from common import saveFile
htmlFile = 'xxrs.html'
def formatMetadata(metadata: dict) -> str: def formatMetadata(metadata: dict) -> str:
@ -11,19 +14,15 @@ def formatMetadata(metadata: dict) -> str:
) )
def formatChapter(caption: str, content: list) -> str:
return '<h2>%s</h2>\n' % caption + '\n'.join(['<p>%s</p>' % x for x in content])
def htmlRelease(metadata: dict, content: dict) -> str: def htmlRelease(metadata: dict, content: dict) -> str:
result = [formatMetadata(metadata)] result = [formatMetadata(metadata)]
for (title, chapter) in content.items(): for (title, chapter) in content.items():
result.append( result.append(
formatChapter(title, chapter) '<h2>%s</h2>\n' % title + '\n'.join(['<p>%s</p>' % x for x in chapter])
) )
return '\n\n'.join(result) return '\n\n'.join(result) + '\n'
if __name__ == '__main__': if __name__ == '__main__':
data = loadData(sys.argv[1]) data = loadData(sys.argv[1])
print(htmlRelease(data['metadata'], data['content'])) saveFile(htmlFile, htmlRelease(data['metadata'], data['content']))
Loading…
Cancel
Save