Created
January 8, 2016 16:38
-
-
Save brianjking/e4a9176a05c0ec0ac40f to your computer and use it in GitHub Desktop.
Convert Markdown to RST for Sphinx automatically using Pandoc - NEEDS TESTED. Obtained via: http://www.pythonbackend.com/topic/1268949527
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 | |
import os | |
import subprocess | |
DOCUMENTATION_SOURCE_DIR = 'documentation/source/' | |
SOURCE_EXTENSION = '.md' | |
OUTPUT_EXTENSION = '.rst' | |
for _, __, filenames in os.walk(DOCUMENTATION_SOURCE_DIR): | |
for filename in filenames: | |
if filename.endswith('.md'): | |
filename_stem = filename.split('.')[0] | |
source_file = DOCUMENTATION_SOURCE_DIR + filename_stem + SOURCE_EXTENSION | |
output_file = DOCUMENTATION_SOURCE_DIR + filename_stem + OUTPUT_EXTENSION | |
command = 'pandoc -s {0} -o {1}'.format(source_file, output_file) | |
print(command) | |
subprocess.call(command.split(' ')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment