Last active
July 25, 2018 08:35
-
-
Save biboc/c20fd032492b840df6f667be308f3238 to your computer and use it in GitHub Desktop.
Transform .asciidoc file to .md with recursive folder
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 python2 | |
import glob | |
import os | |
from os.path import basename | |
OUT_DIRECTORY = "out" | |
os.system("rm -rf " + OUT_DIRECTORY) | |
os.system("mkdir -p " + OUT_DIRECTORY) | |
os.system("cp -R * " + OUT_DIRECTORY) | |
exclude = set([OUT_DIRECTORY]) | |
for root, dirs, files in os.walk(".", topdown=True): | |
dirs[:] = [d for d in dirs if d not in exclude] | |
for file in files: | |
if file.endswith(".asciidoc"): | |
print("##################################################") | |
print(os.path.join(root, file)) | |
print(file) | |
filePath = os.path.join(root, file) | |
cmd = "asciidoctor -b docbook -a leveloffset=+1 -o - " + filePath + \ | |
" | pandoc --atx-headers --wrap=preserve -t markdown_strict -f docbook - > " + \ | |
OUT_DIRECTORY+"/" + filePath + ".md" | |
print(cmd) | |
os.system(cmd) | |
for root, dirs, files in os.walk("out"): | |
for file in files: | |
if file.endswith(".asciidoc"): | |
os.system("rm " + os.path.join(root, file)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment