Browse Source

feat: markdown release function

master
Dnomd343 2 years ago
parent
commit
ba21dae985
  1. 0
      src/release/to_json.py
  2. 31
      src/release/to_markdown.py
  3. 0
      src/release/to_txt.py

0
src/release/to-json.py → src/release/to_json.py

31
src/release/to_markdown.py

@ -0,0 +1,31 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
from common import loadData
def formatMetadata(metadata: dict) -> str:
return '# %s\n\n+ 作者:%s\n\n> %s' % (
metadata['name'],
metadata['author'],
'\n> '.join(metadata['desc']),
)
def formatChapter(caption: str, content: list) -> str:
return '## %s\n\n%s' % (caption, '\n\n'.join(content))
def markdownRelease(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(markdownRelease(data['metadata'], data['content']))

0
src/release/to-txt.py → src/release/to_txt.py

Loading…
Cancel
Save