forked from github/pelican
PELICAN: pelican_import.py: add support for pelican-import -m asciidoc
Signed-off-by: Tim Janik <timj@gnu.org>
This commit is contained in:
parent
adf12505ab
commit
5365a1cdb3
1 changed files with 30 additions and 2 deletions
|
|
@ -571,6 +571,29 @@ def build_header(title, date, author, categories, tags, slug,
|
|||
header += '\n'
|
||||
return header
|
||||
|
||||
def build_asciidoc_header(title, date, author, categories, tags, slug,
|
||||
status=None, attachments=None):
|
||||
"""Build a header from a list of fields"""
|
||||
|
||||
from docutils.utils import column_width
|
||||
|
||||
header = '= %s\n' % title
|
||||
if author:
|
||||
header += '%s\n' % author
|
||||
if date:
|
||||
header += '%s\n' % date
|
||||
if categories:
|
||||
header += ':category: %s\n' % ', '.join(categories)
|
||||
if tags:
|
||||
header += ':tags: %s\n' % ', '.join(tags)
|
||||
if slug:
|
||||
header += ':slug: %s\n' % slug
|
||||
if status:
|
||||
header += ':status: %s\n' % status
|
||||
if attachments:
|
||||
header += ':attachments: %s\n' % ', '.join(attachments)
|
||||
header += '\n'
|
||||
return header
|
||||
|
||||
def build_markdown_header(title, date, author, categories, tags,
|
||||
slug, status=None, attachments=None):
|
||||
|
|
@ -595,7 +618,9 @@ def build_markdown_header(title, date, author, categories, tags,
|
|||
|
||||
|
||||
def get_ext(out_markup, in_markup='html'):
|
||||
if in_markup == 'markdown' or out_markup == 'markdown':
|
||||
if out_markup == 'asciidoc':
|
||||
ext = '.adoc'
|
||||
elif in_markup == 'markdown' or out_markup == 'markdown':
|
||||
ext = '.md'
|
||||
else:
|
||||
ext = '.rst'
|
||||
|
|
@ -775,7 +800,10 @@ def fields2pelican(
|
|||
links = None
|
||||
|
||||
ext = get_ext(out_markup, in_markup)
|
||||
if ext == '.md':
|
||||
if ext == '.adoc':
|
||||
header = build_asciidoc_header(title, date, author, categories,
|
||||
tags, slug, status, attached_files)
|
||||
elif ext == '.md':
|
||||
header = build_markdown_header(
|
||||
title, date, author, categories, tags, slug,
|
||||
status, links.values() if links else None)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue