Refactor readers and remove MARKUP

Add a `Readers` class which contains a dict of file extensions / `Reader`
instances. This dict can be overwritten with a `READERS` settings, for instance
to avoid processing *.html files:

    READERS = {'html': None}

Or to add a custom reader for the `foo` extension:

    READERS = {'foo': FooReader}

This dict is no storing the Reader classes as it was done before with
`EXTENSIONS`. It stores the instances of the Reader classes to avoid instancing
for each file reading.
This commit is contained in:
Simon Conseil 2013-08-04 17:02:58 +02:00
commit 4bc4b1500c
7 changed files with 201 additions and 203 deletions

View file

@ -19,8 +19,8 @@ class ReaderTest(unittest.TestCase):
def read_file(self, path, **kwargs):
# Isolate from future API changes to readers.read_file
return readers.read_file(
base_path=CONTENT_PATH, path=path, settings=get_settings(**kwargs))
r = readers.Readers(settings=get_settings(**kwargs))
return r.read_file(base_path=CONTENT_PATH, path=path)
class RstReaderTest(ReaderTest):
@ -160,7 +160,7 @@ class MdReaderTest(ReaderTest):
' with some footnotes'
'<sup id="fnref:footnote"><a class="footnote-ref" '
'href="#fn:footnote" rel="footnote">2</a></sup></p>\n'
'<div class="footnote">\n'
'<hr />\n<ol>\n<li id="fn:1">\n'
'<p>Numbered footnote&#160;'