How to create options for Python markdown custom extension?

Viewed 195

I'm trying to add an option to my custom markdown extension in python3. Unfortuantely I'm getting the following error:

  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'

The constructor code of the extension is below. It follows the pattern provided by the docs.

class MyFencedCodeExtension(markdown.extensions.Extension):

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

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

I'm referencing the extension when constructing the Markdown instance:

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