Merge pull request #1376 from avaris/remove_asciidoc

Remove AsciiDocReader from core. Fixes #1355
This commit is contained in:
Justin Mayer 2014-06-24 16:02:08 -07:00
commit dbf6d7cf8f
11 changed files with 6 additions and 112 deletions

View file

@ -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.

View file

@ -98,7 +98,6 @@ DEFAULT_CONFIG = {
'PELICAN_CLASS': 'pelican.Pelican',
'DEFAULT_DATE_FORMAT': '%a %d %B %Y',
'DATE_FORMATS': {},
'ASCIIDOC_OPTIONS': [],
'MD_EXTENSIONS': ['codehilite(css_class=highlight)', 'extra'],
'JINJA_EXTENSIONS': [],
'JINJA_FILTERS': {},

View file

@ -1,12 +0,0 @@
Test AsciiDoc File Header
=========================
:Author: Author O. Article
:Email: <author@nowhere.com>
:Date: 2011-09-15 09:05
:Category: Blog
:Tags: Linux, Python, Pelican
Used for pelican test
---------------------
The quick brown fox jumped over the lazy dog's back.

View file

@ -1,9 +0,0 @@
Test AsciiDoc File Header
=========================
Used for pelican test
---------------------
version {revision}
The quick brown fox jumped over the lazy dog's back.

View file

@ -333,42 +333,6 @@ class MdReaderTest(ReaderTest):
self.assertEqual(value, page.metadata[key], key)
class AdReaderTest(ReaderTest):
@unittest.skipUnless(readers.asciidoc, "asciidoc isn't installed")
def test_article_with_asc_extension(self):
# Ensure the asc extension is being processed by the correct reader
page = self.read_file(
path='article_with_asc_extension.asc')
expected = ('<hr>\n<h2><a name="_used_for_pelican_test">'
'</a>Used for pelican test</h2>\n'
'<p>The quick brown fox jumped over'
' the lazy dog&#8217;s back.</p>\n')
self.assertEqual(page.content, expected)
expected = {
'category': 'Blog',
'author': 'Author O. Article',
'title': 'Test AsciiDoc File Header',
'date': datetime.datetime(2011, 9, 15, 9, 5),
'tags': ['Linux', 'Python', 'Pelican'],
}
for key, value in expected.items():
self.assertEqual(value, page.metadata[key], key)
@unittest.skipUnless(readers.asciidoc, "asciidoc isn't installed")
def test_article_with_asc_options(self):
# test to ensure the ASCIIDOC_OPTIONS is being used
reader = readers.AsciiDocReader(
dict(ASCIIDOC_OPTIONS=["-a revision=1.0.42"]))
content, metadata = reader.read(_path('article_with_asc_options.asc'))
expected = ('<hr>\n<h2><a name="_used_for_pelican_test"></a>Used for'
' pelican test</h2>\n<p>version 1.0.42</p>\n'
'<p>The quick brown fox jumped over the lazy'
' dog&#8217;s back.</p>\n')
self.assertEqual(content, expected)
class HTMLReaderTest(ReaderTest):
def test_article_with_comments(self):
page = self.read_file(path='article_with_comments.html')