mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge 7ab2d1fddf into 76eebfe539
This commit is contained in:
commit
a5fe6f3e3c
1 changed files with 22 additions and 3 deletions
|
|
@ -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 "
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue