Jan Černohorský
2 years ago
5 changed files with 62 additions and 5 deletions
@ -0,0 +1,5 @@ |
|||||
|
from panflute import Element |
||||
|
|
||||
|
class commands: |
||||
|
def woah(e: Element) -> Element: |
||||
|
return e |
@ -0,0 +1,18 @@ |
|||||
|
from panflute import Div,Span |
||||
|
from util import * |
||||
|
from typing import Callable |
||||
|
|
||||
|
class Command: |
||||
|
pass |
||||
|
|
||||
|
class InlineCommand(Span, Command): |
||||
|
def call(self, f: Callable) -> Span: |
||||
|
r = f(self) |
||||
|
return replaceEl(self, Span(*r.content, identifier=r.identifier, classes=r.classes, attributes=r.attributes)) |
||||
|
pass |
||||
|
|
||||
|
class MultilineCommand(Div, Command): |
||||
|
def call(self, f: Callable) -> Div: |
||||
|
r = f(self) |
||||
|
return replaceEl(self, Div(*r.content, identifier=r.identifier, classes=r.classes, attributes=r.attributes)) |
||||
|
pass |
@ -0,0 +1,7 @@ |
|||||
|
from panflute import Element |
||||
|
|
||||
|
def replaceEl(e: Element, r: Element) -> Element: |
||||
|
e.parent.content[e.index] = r |
||||
|
return r |
||||
|
def deleteEl(e: Element): |
||||
|
del e.parent.content[e.index] |
Loading…
Reference in new issue