From c90e00a1aef5b1b226d6be4c5338051b3333c94b Mon Sep 17 00:00:00 2001 From: Greenscreener Date: Tue, 27 Feb 2024 10:01:56 +0100 Subject: [PATCH] Fix broken transformation of divs and spans. --- src/formatitko/transform_processor.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/formatitko/transform_processor.py b/src/formatitko/transform_processor.py index 6ce7999..e82cebc 100644 --- a/src/formatitko/transform_processor.py +++ b/src/formatitko/transform_processor.py @@ -131,7 +131,6 @@ class TransformProcessor(NOPProcessor): return super().transform_Para(e) def transform_Div(self, e: Div) -> Union[Div, Group, Null, RawBlock]: - e.content = self.transform(e.content) if "group" in e.classes: # `.group` class for Divs @@ -191,10 +190,9 @@ class TransformProcessor(NOPProcessor): if "lang" in e.attributes: warnings.warn("To set language in a way formátítko will understand, this Div has to have the `.group` class and be a Group.", UserWarning) - return e + return super().transform_Div(e) def transform_Span(self, e: Span) -> Span: - e.content = self.transform(e.content) if "group" in e.classes: # `.group` class for Spans @@ -251,7 +249,7 @@ class TransformProcessor(NOPProcessor): # This is a shorthand for just printing the content of some metadata. elif re.match(r"^\$[\w.]+$", e.content[0].text): val = self.context.get_metadata(e.content[0].text[1:], False) - if isinstance(val, MetaInlines): + if isinstance(val, MetaInlines): # TODO: Trust transform for this e = Span(*val.content) e = self.transform(e) elif isinstance(val, MetaString): @@ -262,7 +260,7 @@ class TransformProcessor(NOPProcessor): raise TypeError(f"Cannot print value of metadatum '{e.content[0].text[1:]}' of type '{type(val)}'") return e - return e + return super().transform_Span(e) def transform_CodeBlock(self, e: CodeBlock) -> Union[CodeBlock, Div, Null]: if "markdown" in e.classes and "group" in e.classes: