python - Lektor 插件开发

标签 python lektor

我正在尝试开发一个 reStructuredText 插件并犯了一些基本错误。

我的插件对象如下所示:

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))

现在:调用 on_setup_env 函数。请注意,我正在替换 markdown 字典条目(目前)。但是当我运行 lektor 时,会调用原始 Markdown 类,而不是我的 RST 类。

最佳答案

这是 Lektor 问题跟踪器中出现的一个问题:https://github.com/lektor/lektor/issues/77

答案是 Lektor 不使用 Jinja 过滤器来处理字段类型。相反,人们必须实现如下所示的类型: https://www.getlektor.com/docs/api/db/type/

但这需要目前正在开发的 Lektor 2.0。

关于python - Lektor 插件开发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34631288/

相关文章:

markdown - 支持 lektor 中的 RST 标记?

python - 使用 PyGTK 进行线程化

python - 如何从 Python 列表中删除日期

python - 如何在 weasyprint 中使用自定义字体

python - 如何使用 Pillow 读取原始 RGBA4444 图像?

python - tensorflow 2 keras shuffle每一行梯度问题

python - Lektor 中的本地化/翻译路径