Skip to content

Commit

Permalink
Fall back on markdown if pandoc isn't available
Browse files Browse the repository at this point in the history
This is less than ideal, but I think it'll suffice for now
  • Loading branch information
ForeverWintr committed Jun 11, 2017
1 parent 242775a commit 8004120
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import os
import contextlib
import pathlib
import shutil
from setuptools import setup, find_packages

import pandoc
has_pandoc = True
try:
import pandoc
except ImportError:
has_pandoc = False

import metafunctions

Expand All @@ -17,10 +22,13 @@ def md_to_rst(dir_):
dir_ = pathlib.Path(dir_)
rstfiles = []
for mdfile in dir_.glob('*.md'):
doc = pandoc.Document()
doc.markdown = mdfile.read_bytes()
rstfile = mdfile.with_suffix('.rst')
rstfile.write_bytes(doc.rst)
if has_pandoc:
doc = pandoc.Document()
doc.markdown = mdfile.read_bytes()
rstfile.write_bytes(doc.rst)
else:
shutil.copy(mdfile, rstfile)
rstfiles.append(rstfile)

yield rstfiles
Expand Down

0 comments on commit 8004120

Please sign in to comment.