|
@ -20,6 +20,7 @@ class OutputGenerator: |
|
|
self.indent_str = indent_str |
|
|
self.indent_str = indent_str |
|
|
self.indent_level = initial_indent_level |
|
|
self.indent_level = initial_indent_level |
|
|
self._at_start_of_line = True |
|
|
self._at_start_of_line = True |
|
|
|
|
|
self.current_context = None |
|
|
|
|
|
|
|
|
self.TYPE_DICT_MISC = { |
|
|
self.TYPE_DICT_MISC = { |
|
|
TableRow: self.generate_TableRow, |
|
|
TableRow: self.generate_TableRow, |
|
@ -87,6 +88,9 @@ class OutputGenerator: |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
def generate(self, e: Union[Element, ListContainer, list[Union[Element, ListContainer]]]): |
|
|
def generate(self, e: Union[Element, ListContainer, list[Union[Element, ListContainer]]]): |
|
|
|
|
|
if isinstance(e, Group): |
|
|
|
|
|
old_context = self.current_context |
|
|
|
|
|
self.current_context = e.context |
|
|
if isinstance(e, list): |
|
|
if isinstance(e, list): |
|
|
for el in e: |
|
|
for el in e: |
|
|
self.generate(el) |
|
|
self.generate(el) |
|
@ -101,6 +105,8 @@ class OutputGenerator: |
|
|
self.TYPE_DICT_MISC[type(e)](e) |
|
|
self.TYPE_DICT_MISC[type(e)](e) |
|
|
except KeyError: |
|
|
except KeyError: |
|
|
raise UnknownElementError(type(e)) |
|
|
raise UnknownElementError(type(e)) |
|
|
|
|
|
if isinstance(e, Group): |
|
|
|
|
|
self.current_context = old_context |
|
|
|
|
|
|
|
|
def escape_special_chars(self, text: str) -> str: |
|
|
def escape_special_chars(self, text: str) -> str: |
|
|
return text |
|
|
return text |
|
|