Last active
October 1, 2021 06:32
-
-
Save lele-blue/7a494bcea31373cd09a2097d785544fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| import os | |
| summary = open("book/SUMMARY.md", "r").read().splitlines() | |
| order = ["SUMMARY.md"] | |
| for summary_line in summary: | |
| pattern = re.compile(r" *[\*\-] ?\[(.+)\] ?\((.+)\)") | |
| if re.match(pattern, summary_line): | |
| order.append(re.findall(pattern, summary_line)[0][1]) | |
| out = open("out.md", "w") | |
| for chapter in order: | |
| out.write(open(os.path.join("book", chapter), "r").read() + "\n") |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pandoc -o book.epub meta.yml out.md --toc --toc-depth=2 --css=css.css