This commit is contained in:
David Wilemski 2018-07-10 06:04:46 +00:00 committed by GitHub
commit a5fe6f3e3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -689,6 +689,9 @@ def fields2pelican(
dircat=False, strip_raw=False, disable_slugs=False,
dirpage=False, filename_template=None, filter_author=None,
wp_custpost=False, wp_attach=False, attachments=None):
pandoc2 = is_pandoc2_installed()
for (title, content, filename, date, author, categories, tags, status,
kind, in_markup) in fields:
if filter_author and filter_author != author:
@ -735,9 +738,13 @@ def fields2pelican(
fp.write(new_content)
parse_raw = '--parse-raw' if not strip_raw else ''
cmd = ('pandoc --normalize {0} --from=html'
' --to={1} -o "{2}" "{3}"')
parse_raw = '--parse-raw' if not strip_raw and not pandoc2 else ''
if pandoc2:
cmd = ('pandoc {0} --from=html '
'--to=gfm+raw_html -o "{2}" "{3}"')
else:
cmd = ('pandoc --normalize {0} --from=html'
' --to={1} -o "{2}" "{3}"')
cmd = cmd.format(parse_raw, out_markup,
out_filename, html_filename)
@ -775,6 +782,18 @@ def fields2pelican(
download_attachments(output_path, urls)
def is_pandoc2_installed():
cmd = ['pandoc', '--version']
try:
output = subprocess.check_output(cmd).decode('utf-8')
except subprocess.CalledProcessError:
return None
if re.search(r'^pandoc 2\..+$', output, re.M):
return True
return False
def main():
parser = argparse.ArgumentParser(
description="Transform feed, WordPress, Tumblr, Dotclear, or "