Browse Source

feat: standard html format

master
Dnomd343 2 years ago
parent
commit
3dc57b87f5
  1. 4
      src/release/release.py
  2. 27
      src/release/utils/sequence.py

4
src/release/release.py

@ -13,6 +13,6 @@ metadata, content = loadBook('rc-5')
# txtRelease(metadata, content) # txtRelease(metadata, content)
# jsonRelease(metadata, content) # jsonRelease(metadata, content)
# htmlRelease(metadata, content) htmlRelease(metadata, content)
staticRelease(metadata, content) # staticRelease(metadata, content)
# gitbookRelease(metadata, content) # gitbookRelease(metadata, content)

27
src/release/utils/sequence.py

@ -40,21 +40,20 @@ def txtSerialize(metadata: dict, content: dict) -> str:
return '\n\n\n'.join(result) + '\n' return '\n\n\n'.join(result) + '\n'
def htmlMetadata(metadata: dict) -> str: # html metadata
return '<h1>%s</h1>\n' % metadata['name'] + '\n'.join(
['<p>%s</p>' % x for x in metadata['desc']]
)
def htmlSerialize(metadata: dict, content: dict) -> str: def htmlSerialize(metadata: dict, content: dict) -> str:
result = [htmlMetadata(metadata)] htmlContent = [
for (title, chapter) in content.items(): '<?xml version=\'1.0\' encoding=\'utf-8\'?>',
result.append( '<html xmlns="http://www.w3.org/1999/xhtml">',
'<h2>%s</h2>\n' % title + '\n'.join( '<head>', '<title>%s</title>' % metadata['name'],
['<p>%s</p>' % x for x in chapter] '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>',
) '</head>', '<body>', '<h1>%s</h1>' % metadata['name'],
) ]
return '\n\n'.join(result) + '\n' htmlContent += ['<p>%s</p>' % x for x in metadata['desc']]
for (caption, chapter) in content.items():
htmlContent.append('<h2>%s</h2>' % caption)
htmlContent.append('\n'.join(['<p>%s</p>' % x for x in chapter]))
htmlContent += ['</body>', '</html>']
return '\n'.join(htmlContent) + '\n'
def gitbookMetadata(metadata: dict) -> str: def gitbookMetadata(metadata: dict) -> str:

Loading…
Cancel
Save