Misaka Python:“超级”对象没有属性“段落”

时间:2019-09-14 13:46:51

标签: python python-cffi misaka hoedown

我正在创建一个客户渲染器,以向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'

0 个答案:

没有答案