|
|
@ -3,7 +3,10 @@ |
|
|
|
|
|
|
|
import os |
|
|
|
import re |
|
|
|
import sys |
|
|
|
import shutil |
|
|
|
from common import loadData |
|
|
|
from common import rootPath |
|
|
|
from common import saveFile |
|
|
|
from common import createFolder |
|
|
|
|
|
|
@ -35,15 +38,16 @@ def loadChapters(chapters: dict) -> dict: |
|
|
|
|
|
|
|
|
|
|
|
def loadCover(metadata: dict) -> None: |
|
|
|
cover = '---\ndescription: 作者:%s\n---\n\n# %s\n\n' % (metadata['author'], metadata['name']) |
|
|
|
cover += '<figure><img src="assets/cover.jpg" alt=""><figcaption></figcaption></figure>\n\n' |
|
|
|
cover += '\n>\n'.join(['> %s' % x for x in metadata['desc']]) |
|
|
|
cover = '---\ndescription: 作者:%s\n---\n\n# 栩栩若生\n\n' % metadata['author'] |
|
|
|
cover += '<figure><img src="assets/cover.jpg" alt=""><figcaption><p>栩栩若生</p></figcaption></figure>\n\n' |
|
|
|
cover += '\n>\n'.join(['> %s' % x for x in metadata['desc']]) + '\n\n' |
|
|
|
cover += '{% embed url="https://github.com/dnomd343/xxrs-crawler.git" %}\n项目地址\n{% endembed %}\n' |
|
|
|
saveFile(os.path.join(workDir, 'README.md'), cover + '\n') |
|
|
|
|
|
|
|
|
|
|
|
def loadSummary(catalog: dict) -> None: |
|
|
|
summary = '# XXRS\n\n' |
|
|
|
summary += '* [栩栩若生](README.md)\n\n' |
|
|
|
summary += '* [序言](README.md)\n\n' |
|
|
|
summary += '## 内容 <a href="#content" id="content"></a>\n\n' |
|
|
|
for (title, mdFile) in catalog.items(): |
|
|
|
summary += '* [%s](content/%s)\n' % (title, mdFile) |
|
|
@ -55,8 +59,12 @@ def loadGitbook(jsonName: str) -> None: |
|
|
|
loadCover(data['metadata']) |
|
|
|
catalog = loadChapters(data['content']) |
|
|
|
loadSummary(catalog) |
|
|
|
shutil.copy( |
|
|
|
os.path.join(rootPath, './assets/cover.jpg'), |
|
|
|
os.path.join(workDir, './assets/cover.jpg') |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
initFolder() |
|
|
|
loadGitbook('rc-4') |
|
|
|
loadGitbook(sys.argv[1]) |
|
|
|