Search code examples
pythonlektor

Plugin Development for Lektor


I am trying to develop a reStructuredText plugin and doing some basic mistake.

My plugin object looks like this:

class RSTPlugin(Plugin):
    name = 'RST'
    description = 'RST plugin'

    def on_setup_env(self, **extra):
        self.env.jinja_env.filters['markdown'] = \
            jinja2.contextfilter(lambda ctx, *a, **kw: RST(*a, **kw))

Now: the on_setup_env function is called. Notice that I am replacing the markdown dict entry (for now). But when I run lektor the original Markdown class is called and not my RST one.


Solution

  • This is a question that come up in the Lektor issue tracker: https://github.com/lektor/lektor/issues/77

    The answer is that Lektor does not use Jinja filters for field types. Instead one has to implement a type like here: https://www.getlektor.com/docs/api/db/type/

    This however requires Lektor 2.0 which is currently in development.