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. ...@@ -11,20 +11,26 @@ is not cumbersome in the daily workflow.
import os import os
from pelican import signals from pelican import signals
from pelican.readers import RstReader from pelican.readers import RstReader
import docutils.io
import docutils.core
class RstReaderWrapper(RstReader): class RstReaderWrapper(RstReader):
enabled = RstReader.enabled enabled = RstReader.enabled
file_extensions = ['rst'] file_extensions = ['rst']
class FileInput(RstReader.FileInput): class FileInput(docutils.io.FileInput):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
RstReader.FileInput_.__init__(self, *args, **kwargs) super().__init__(*args, **kwargs)
self.source = RstReaderWrapper.SourceWrapper(self.source) self.source = RstReaderWrapper.SourceWrapper(self.source)
# Hook into RstReader class Publisher(docutils.core.Publisher):
RstReader.FileInput_ = RstReader.FileInput def __init__(self, *args, **kwargs):
RstReader.FileInput = FileInput 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: 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