Misaka Python:“super”对象没有“paragraph”属性

2024-05-14 14:19:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在创建一个客户渲染器,以向Markdown添加警告标记。 我正在使用misaka。这是密码

import misaka as m
import re
import houdini as h


class CustomHTMLRenderer(m.HtmlRenderer):
    def paragraph(self, content):
        _prefix_re = re.compile(r'^\s*(!{1,4})\s+')

        CLASSES = {
            1: 'note',
            2: 'info',
            3: 'tip',
            4: 'warning',
        }

        match = _prefix_re.match(content)
        if match is None:
            return super(CustomHTMLRenderer, self).paragraph(content)  ## this call is the problem
        else:
            # do something
            pass


调用paragraph()方法时,我得到以下错误:

AttributeError: 'super' object has no attribute 'paragraph'
From cffi callback <function cb_paragraph at 0x7f4fb4108b70>:
Traceback (most recent call last):
  File "/home/x/project/env/lib/python3.6/site-packages/misaka/callbacks.py", line 82, in cb_paragraph
    result = renderer.paragraph(content)
  File "/home/x/project/django_project/wiki/utils.py", line 99, in paragraph
    return super(CustomHTMLRenderer, self).paragraph(content)
AttributeError: 'super' object has no attribute 'paragraph'

Tags: importselfreprojectprefixreturnisas

热门问题