|
@ -17,7 +17,7 @@ from .context import Group, InlineGroup, BlockGroup |
|
|
from .util import nullify, import_md |
|
|
from .util import nullify, import_md |
|
|
from .context import Context, CommandCallable |
|
|
from .context import Context, CommandCallable |
|
|
from .whitespace import Whitespace, bavlna |
|
|
from .whitespace import Whitespace, bavlna |
|
|
from .command import BlockCommand, InlineCommand, Command |
|
|
from .command import BlockCommand, InlineCommand, CodeCommand, Command |
|
|
from .command_util import handle_command_define, parse_command |
|
|
from .command_util import handle_command_define, parse_command |
|
|
|
|
|
|
|
|
ELCl = Union[Element, ListContainer, list[Union[Element, ListContainer]]] |
|
|
ELCl = Union[Element, ListContainer, list[Union[Element, ListContainer]]] |
|
@ -104,7 +104,8 @@ class TransformProcessor: |
|
|
FQuoted: self.transform_FQuoted, |
|
|
FQuoted: self.transform_FQuoted, |
|
|
|
|
|
|
|
|
InlineCommand: self.transform_InlineCommand, |
|
|
InlineCommand: self.transform_InlineCommand, |
|
|
BlockCommand: self.transform_BlockCommand |
|
|
BlockCommand: self.transform_BlockCommand, |
|
|
|
|
|
CodeCommand: self.transform_CodeCommand |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
def add_command_module(self, module: Union[dict[str, CommandCallable], ModuleType], module_name: str=""): |
|
|
def add_command_module(self, module: Union[dict[str, CommandCallable], ModuleType], module_name: str=""): |
|
@ -507,6 +508,8 @@ class TransformProcessor: |
|
|
return nullify(e) |
|
|
return nullify(e) |
|
|
return handle_command_define(e, self.context) |
|
|
return handle_command_define(e, self.context) |
|
|
|
|
|
|
|
|
|
|
|
if "c" in e.attributes: |
|
|
|
|
|
return self.transform(CodeCommand(e.text, identifier=e.identifier, classes=e.classes, attributes=e.attributes)) |
|
|
|
|
|
|
|
|
# Pass down metadata 'highlight' and 'highlight_style' as attribute to CodeBlocks |
|
|
# Pass down metadata 'highlight' and 'highlight_style' as attribute to CodeBlocks |
|
|
# OG now has Context so this is not needed per se, but I'm keeping this here for the handling of attribute > context > default value |
|
|
# OG now has Context so this is not needed per se, but I'm keeping this here for the handling of attribute > context > default value |
|
@ -529,6 +532,9 @@ class TransformProcessor: |
|
|
def transform_BlockCommand(self, e: BlockCommand) -> Div: |
|
|
def transform_BlockCommand(self, e: BlockCommand) -> Div: |
|
|
return self.transform_Command(e) |
|
|
return self.transform_Command(e) |
|
|
|
|
|
|
|
|
|
|
|
def transform_CodeCommand(self, e: CodeCommand) -> Div: |
|
|
|
|
|
return self.transform_Command(e) |
|
|
|
|
|
|
|
|
def transform_Whitespace(self, e: Whitespace) -> Whitespace: |
|
|
def transform_Whitespace(self, e: Whitespace) -> Whitespace: |
|
|
if bavlna(e, self.context): |
|
|
if bavlna(e, self.context): |
|
|
return NBSP() |
|
|
return NBSP() |
|
|