mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
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'
|
header += '\n'
|
||||||
return header
|
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,
|
def build_markdown_header(title, date, author, categories, tags,
|
||||||
slug, status=None, attachments=None):
|
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'):
|
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'
|
ext = '.md'
|
||||||
else:
|
else:
|
||||||
ext = '.rst'
|
ext = '.rst'
|
||||||
|
|
@ -775,7 +800,10 @@ def fields2pelican(
|
||||||
links = None
|
links = None
|
||||||
|
|
||||||
ext = get_ext(out_markup, in_markup)
|
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(
|
header = build_markdown_header(
|
||||||
title, date, author, categories, tags, slug,
|
title, date, author, categories, tags, slug,
|
||||||
status, links.values() if links else None)
|
status, links.values() if links else None)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue