from panflute import Div,Span,Para from util import * from typing import List class Command: pass class InlineCommand(Span, Command): def replaceSelf(self, content: List[Element]) -> Span: try: return Span(*content) except TypeError: if len(content) == 1 and isinstance(content[0], Para): return Span(*content[0].content) else: return Div(*content) pass class MultilineCommand(Div, Command): def replaceSelf(self, content: List[Element]) -> Div: return Div(*content) pass