final fix for dotclear import

This commit is contained in:
Nicolas Steinmetz 2011-08-30 22:27:43 +02:00
commit 8f6da4fa7f

View file

@ -113,14 +113,17 @@ def dc2fields(file):
if cat_id:
categories = [category_list[id].strip() for id in cat_id.split(',')]
if (post_format == "markdown") or (post_format == "wiki"):
"""
Weird - dotclear2 at least does not use markdown ; so wonder about the use case on "markdown"
"""
if post_format == "markdown":
content = post_excerpt + post_content
else:
content = post_excerpt_xhtml + post_content_xhtml
content = content.replace('\\n', '')
post_format = "html"
yield (post_title, content, post_url, post_creadt, author, categories, tags, post_format)
yield (post_title, content, slugify(post_title), post_creadt, author, categories, tags, post_format)
def feed2fields(file):
@ -163,7 +166,7 @@ def build_markdown_header(title, date, author, categories, tags):
def fields2pelican(fields, output_path, dircat=False):
for title, content, filename, date, author, categories, tags, markup in fields:
if (markup == "markdown") or (markup == "wiki"):
if (markup == "markdown"):
ext = '.md'
header = build_markdown_header(title, date, author, categories, tags)
else:
@ -175,7 +178,7 @@ def fields2pelican(fields, output_path, dircat=False):
# option to put files in directories with categories names
if dircat and (len(categories) == 1):
catname = slugify(categories[0])
out_filename = os.path.join(output_path, catname, filename+'.rst')
out_filename = os.path.join(output_path, catname, filename+ext)
if not os.path.isdir(os.path.join(output_path, catname)):
os.mkdir(os.path.join(output_path, catname))
else:
@ -189,8 +192,7 @@ def fields2pelican(fields, output_path, dircat=False):
with open(html_filename, 'w', encoding='utf-8') as fp:
fp.write(content)
os.system('pandoc --normalize --reference-links --from=html --to=rst -o "%s" "%s"' % (out_filename,
html_filename))
os.system('pandoc --normalize --reference-links --from=html --to=rst -o "%s" "%s"' % (out_filename, html_filename))
os.remove(html_filename)