Commit b090840b authored by Roland Denis's avatar Roland Denis
Browse files

Fixing FileInput hook with Pelican version 4.5.0

It is used in rst_include plugin to prefix all rst file with aliases
defined in include.rst
parent 894cd5a8
......@@ -11,20 +11,26 @@ is not cumbersome in the daily workflow.
import os
from pelican import signals
from pelican.readers import RstReader
import docutils.core
class RstReaderWrapper(RstReader):
enabled = RstReader.enabled
file_extensions = ['rst']
class FileInput(RstReader.FileInput):
class FileInput(
def __init__(self, *args, **kwargs):
RstReader.FileInput_.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)
self.source = RstReaderWrapper.SourceWrapper(self.source)
# Hook into RstReader
RstReader.FileInput_ = RstReader.FileInput
RstReader.FileInput = FileInput
class Publisher(docutils.core.Publisher):
def __init__(self, *args, **kwargs):
kwargs['source_class'] = RstReaderWrapper.FileInput
super().__init__(*args, **kwargs)
# Hook into docutils to intercept Publisher construction
# in pelican.RstReader._get_publisher and add the `source_class` arg.
docutils.core.Publisher = Publisher
class SourceWrapper:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment