Commit b090840b authored by Roland Denis's avatar Roland Denis

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
Pipeline #8538 passed with stages
in 1 minute and 37 seconds
......@@ -11,20 +11,26 @@ is not cumbersome in the daily workflow.
import os
from pelican import signals
from pelican.readers import RstReader
import docutils.io
import docutils.core
class RstReaderWrapper(RstReader):
enabled = RstReader.enabled
file_extensions = ['rst']
class FileInput(RstReader.FileInput):
class FileInput(docutils.io.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:
"""
......
Markdown is supported
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