mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Remove AsciiDocReader from core. Fixes #1355
This commit is contained in:
parent
ef96705677
commit
bf9316bb7e
11 changed files with 6 additions and 112 deletions
|
|
@ -17,11 +17,6 @@ try:
|
|||
from markdown import Markdown
|
||||
except ImportError:
|
||||
Markdown = False # NOQA
|
||||
try:
|
||||
from asciidocapi import AsciiDocAPI
|
||||
asciidoc = True
|
||||
except ImportError:
|
||||
asciidoc = False
|
||||
try:
|
||||
from html import escape
|
||||
except ImportError:
|
||||
|
|
@ -349,40 +344,6 @@ class HTMLReader(BaseReader):
|
|||
return parser.body, metadata
|
||||
|
||||
|
||||
class AsciiDocReader(BaseReader):
|
||||
"""Reader for AsciiDoc files"""
|
||||
|
||||
enabled = bool(asciidoc)
|
||||
file_extensions = ['asc', 'adoc', 'asciidoc']
|
||||
default_options = ["--no-header-footer", "-a newline=\\n"]
|
||||
|
||||
def read(self, source_path):
|
||||
"""Parse content and metadata of asciidoc files"""
|
||||
from cStringIO import StringIO
|
||||
with pelican_open(source_path) as source:
|
||||
text = StringIO(source)
|
||||
content = StringIO()
|
||||
ad = AsciiDocAPI()
|
||||
|
||||
options = self.settings['ASCIIDOC_OPTIONS']
|
||||
if isinstance(options, (str, unicode)):
|
||||
options = [m.strip() for m in options.split(',')]
|
||||
options = self.default_options + options
|
||||
for o in options:
|
||||
ad.options(*o.split())
|
||||
|
||||
ad.execute(text, content, backend="html4")
|
||||
content = content.getvalue()
|
||||
|
||||
metadata = {}
|
||||
for name, value in ad.asciidoc.document.attributes.items():
|
||||
name = name.lower()
|
||||
metadata[name] = self.process_metadata(name, value)
|
||||
if 'doctitle' in metadata:
|
||||
metadata['title'] = metadata['doctitle']
|
||||
return content, metadata
|
||||
|
||||
|
||||
class Readers(FileStampDataCacher):
|
||||
"""Interface for all readers.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue