mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
final fix for dotclear import
This commit is contained in:
parent
de790b9e72
commit
8f6da4fa7f
1 changed files with 8 additions and 6 deletions
|
|
@ -113,14 +113,17 @@ def dc2fields(file):
|
||||||
if cat_id:
|
if cat_id:
|
||||||
categories = [category_list[id].strip() for id in cat_id.split(',')]
|
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
|
content = post_excerpt + post_content
|
||||||
else:
|
else:
|
||||||
content = post_excerpt_xhtml + post_content_xhtml
|
content = post_excerpt_xhtml + post_content_xhtml
|
||||||
content = content.replace('\\n', '')
|
content = content.replace('\\n', '')
|
||||||
post_format = "html"
|
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):
|
def feed2fields(file):
|
||||||
|
|
@ -163,7 +166,7 @@ def build_markdown_header(title, date, author, categories, tags):
|
||||||
|
|
||||||
def fields2pelican(fields, output_path, dircat=False):
|
def fields2pelican(fields, output_path, dircat=False):
|
||||||
for title, content, filename, date, author, categories, tags, markup in fields:
|
for title, content, filename, date, author, categories, tags, markup in fields:
|
||||||
if (markup == "markdown") or (markup == "wiki"):
|
if (markup == "markdown"):
|
||||||
ext = '.md'
|
ext = '.md'
|
||||||
header = build_markdown_header(title, date, author, categories, tags)
|
header = build_markdown_header(title, date, author, categories, tags)
|
||||||
else:
|
else:
|
||||||
|
|
@ -175,7 +178,7 @@ def fields2pelican(fields, output_path, dircat=False):
|
||||||
# option to put files in directories with categories names
|
# option to put files in directories with categories names
|
||||||
if dircat and (len(categories) == 1):
|
if dircat and (len(categories) == 1):
|
||||||
catname = slugify(categories[0])
|
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)):
|
if not os.path.isdir(os.path.join(output_path, catname)):
|
||||||
os.mkdir(os.path.join(output_path, catname))
|
os.mkdir(os.path.join(output_path, catname))
|
||||||
else:
|
else:
|
||||||
|
|
@ -189,8 +192,7 @@ def fields2pelican(fields, output_path, dircat=False):
|
||||||
with open(html_filename, 'w', encoding='utf-8') as fp:
|
with open(html_filename, 'w', encoding='utf-8') as fp:
|
||||||
fp.write(content)
|
fp.write(content)
|
||||||
|
|
||||||
os.system('pandoc --normalize --reference-links --from=html --to=rst -o "%s" "%s"' % (out_filename,
|
os.system('pandoc --normalize --reference-links --from=html --to=rst -o "%s" "%s"' % (out_filename, html_filename))
|
||||||
html_filename))
|
|
||||||
|
|
||||||
os.remove(html_filename)
|
os.remove(html_filename)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue