mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add asciidoc reader support
http://www.methods.co.nz/asciidoc/index.html Processes files ending in .asc with asciidoc. Extra arguments can be passed by using the ASCIIDOC_OPTIONS config setting
This commit is contained in:
parent
f9e7c86a1a
commit
49f481e399
9 changed files with 114 additions and 6 deletions
12
tests/content/article_with_asc_extension.asc
Normal file
12
tests/content/article_with_asc_extension.asc
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
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.
|
||||
9
tests/content/article_with_asc_options.asc
Normal file
9
tests/content/article_with_asc_options.asc
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
Test AsciiDoc File Header
|
||||
=========================
|
||||
|
||||
Used for pelican test
|
||||
---------------------
|
||||
|
||||
version {revision}
|
||||
|
||||
The quick brown fox jumped over the lazy dog's back.
|
||||
|
|
@ -109,3 +109,46 @@ class MdReaderTest(unittest.TestCase):
|
|||
'<h3 id="level2">Level2</h3>'
|
||||
|
||||
self.assertEqual(content, expected)
|
||||
|
||||
class AdReaderTest(unittest.TestCase):
|
||||
|
||||
@unittest.skipUnless(readers.asciidoc, "asciidoc isn't installed")
|
||||
def test_article_with_asc_extension(self):
|
||||
# test to ensure the asc extension is being processed by the correct reader
|
||||
reader = readers.AsciiDocReader({})
|
||||
content, metadata = reader.read(_filename('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’s back.</p>\n'
|
||||
self.assertEqual(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.assertEquals(value, metadata[key], key)
|
||||
|
||||
|
||||
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.assertEquals(value, 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(_filename('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’s back.</p>\n'
|
||||
self.assertEqual(content, expected)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue