Created
September 28, 2016 08:12
-
-
Save twlz0ne/fd533ff66d8e11f1fb63402b2e375d29 to your computer and use it in GitHub Desktop.
Generate epub of JavaScript-Garden from markdown
This file contains 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
#!/usr/bin/env python | |
# -*- code: utf-8 -*- | |
# | |
# Generate epub from markdown | |
# | |
# Usage: | |
# cd /path/to/repo | |
# python javascript-garden-epub.py [lang] | |
# | |
# @author gongqijian@gmail.com | |
# @date 2016-09-27 | |
# | |
from __future__ import division, print_function | |
import os, sys, json | |
def convert(lang): | |
with open('doc/%s/index.json' % lang) as json_data: | |
mds = [] | |
index = json.load(json_data) | |
for section in index['sections']: | |
for article in section['articles']: | |
mds.append('doc/%s/%s/%s.md' % (lang, section['dir'], article)) | |
os.system('pandoc {mds} --epub-stylesheet site/style/print.css -o Javascript-Garden_{lang}.epub'.format( | |
mds = ' '.join(mds), lang = lang)) | |
if __name__ == '__main__': | |
convert(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment