mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge pull request #1376 from avaris/remove_asciidoc
Remove AsciiDocReader from core. Fixes #1355
This commit is contained in:
commit
dbf6d7cf8f
11 changed files with 6 additions and 112 deletions
|
|
@ -5,10 +5,8 @@ python:
|
|||
- "3.4"
|
||||
before_install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq --no-install-recommends asciidoc
|
||||
- sudo locale-gen fr_FR.UTF-8 tr_TR.UTF-8
|
||||
install:
|
||||
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then ln -s /usr/share/asciidoc/asciidocapi.py ~/virtualenv/python2.7/lib/python2.7/site-packages/; fi
|
||||
- pip install .
|
||||
- pip install -r dev_requirements.txt
|
||||
- pip install nose-cov
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ pattern::
|
|||
|
||||
This is the content of my super blog post.
|
||||
|
||||
Conventions for AsciiDoc_ posts, which should have an ``.asc`` extension, can
|
||||
be found on the AsciiDoc_ site.
|
||||
Readers for additional formats (such as AsciiDoc_) are available via plugins.
|
||||
Refer to `pelican-plugins`_ repository for those.
|
||||
|
||||
Pelican can also process HTML files ending in ``.html`` and ``.htm``. Pelican
|
||||
interprets the HTML in a very straightforward manner, reading metadata from
|
||||
|
|
@ -369,3 +369,4 @@ listed on the index page nor on any category or tag page.
|
|||
|
||||
.. _W3C ISO 8601: http://www.w3.org/TR/NOTE-datetime
|
||||
.. _AsciiDoc: http://www.methods.co.nz/asciidoc/
|
||||
.. _pelican-plugins: http://github.com/getpelican/pelican-plugins
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ Pelican |release|
|
|||
Pelican is a static site generator, written in Python_. Highlights include:
|
||||
|
||||
* Write your content directly with your editor of choice
|
||||
in reStructuredText_, Markdown_, or AsciiDoc_ formats
|
||||
in reStructuredText_ or Markdown_ formats
|
||||
* Includes a simple CLI tool to (re)generate your site
|
||||
* Easy to interface with distributed version control systems and web hooks
|
||||
* Completely static output is easy to host anywhere
|
||||
|
|
@ -89,7 +89,6 @@ Documentation
|
|||
.. _Python: http://www.python.org/
|
||||
.. _reStructuredText: http://docutils.sourceforge.net/rst.html
|
||||
.. _Markdown: http://daringfireball.net/projects/markdown/
|
||||
.. _AsciiDoc: http://www.methods.co.nz/asciidoc/index.html
|
||||
.. _Jinja2: http://jinja.pocoo.org/
|
||||
.. _`Pelican documentation`: http://docs.getpelican.com/latest/
|
||||
.. _`Pelican's internals`: http://docs.getpelican.com/en/latest/internals.html
|
||||
|
|
|
|||
|
|
@ -52,10 +52,6 @@ installed::
|
|||
|
||||
pip install typogrify
|
||||
|
||||
If you want to use AsciiDoc_ you need to install it from `source
|
||||
<http://www.methods.co.nz/asciidoc/INSTALL.html>`_ or use your operating
|
||||
system's package manager.
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
|
|
@ -119,4 +115,3 @@ The next step is to begin to adding content to the *content* folder that has
|
|||
been created for you.
|
||||
|
||||
.. _virtualenv: http://www.virtualenv.org/
|
||||
.. _AsciiDoc: http://www.methods.co.nz/asciidoc/
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ Overall structure
|
|||
=================
|
||||
|
||||
What Pelican does is take a list of files and process them into some sort of
|
||||
output. Usually, the input files are reStructuredText, Markdown and AsciiDoc
|
||||
output. Usually, the input files are reStructuredText and Markdown
|
||||
files, and the output is a blog, but both input and output can be anything you
|
||||
want.
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ The logic is separated into different classes and concepts:
|
|||
on. Since those operations are commonly used, the object is created once and
|
||||
then passed to the generators.
|
||||
|
||||
* **Readers** are used to read from various formats (AsciiDoc, HTML, Markdown and
|
||||
* **Readers** are used to read from various formats (HTML, Markdown and
|
||||
reStructuredText for now, but the system is extensible). Given a file, they
|
||||
return metadata (author, tags, category, etc.) and content (HTML-formatted).
|
||||
|
||||
|
|
|
|||
|
|
@ -159,8 +159,6 @@ Setting name (followed by default value, if any)
|
|||
Can be used to separate templates from the theme.
|
||||
Example: projects, resume, profile ...
|
||||
These templates need to use ``DIRECT_TEMPLATES`` setting.
|
||||
``ASCIIDOC_OPTIONS = []`` A list of options to pass to AsciiDoc. See the `manpage
|
||||
<http://www.methods.co.nz/asciidoc/manpage.html>`_.
|
||||
``WITH_FUTURE_DATES = True`` If disabled, content with dates in the future will get a default
|
||||
status of ``draft``. See :ref:`reading_only_modified_content`
|
||||
for caveats.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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': {},
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -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.
|
||||
|
|
@ -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’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’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')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue