2

我正在尝试在 python3 中为我的自定义降价扩展添加一个选项。不幸的是,我收到以下错误:

  File "pymodules/docmarkdown.py", line 232, in get_leaflang_markdown
    MyFencedCodeExtension(deflang = "leaf"),
  File "pymodules/docmarkdown.py", line 61, in __init__
    super(MyFencedCodeExtension,self).__init__(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'deflang'

扩展的构造函数代码如下。它遵循docs提供的模式。

class MyFencedCodeExtension(markdown.extensions.Extension):

    def __init__(self, **kwargs):
        self.config = { 'deflang' : [ None, "language if not specified" ] }

        super(MyFencedCodeExtension,self).__init__(**kwargs)

我在构建 Markdown 实例时引用了扩展:

return markdown.Markdown(
    safe_mode = 'escape',
    extensions = [
        'meta',
        'toc',
        MyFencedCodeExtension(deflang = "leaf"),
        CenterExtension({}),
    ]
4

1 回答 1

0

此错误消息发生在您的super()通话中。

的超类MyFencedCodeExtensionmarkdown.extensions.Extension

根据错误消息,超类构造函数不期望关键字参数deflang

查看签名markdown.extensions.Extension.__init__以了解它的预期。

于 2017-07-23T22:31:53.170 回答