diff options
Diffstat (limited to 'textoutpc/_translate.py')
-rwxr-xr-x | textoutpc/_translate.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/textoutpc/_translate.py b/textoutpc/_translate.py index 60ce90b..f3a9c50 100755 --- a/textoutpc/_translate.py +++ b/textoutpc/_translate.py @@ -36,7 +36,13 @@ class _TweaksDictionary: return f"{self.__class__.__name__}({repr(self.__elts)})" def __getitem__(self, key): - return self.__elts[key] + return self.__elts[self.__normalize(key)] + + def __getattr__(self, key): + try: + return self.__elts[self.__normalize(key)] + except: + raise AttributeError(key) def __normalize(self, name): return ''.join(c for c in name if c in _string.ascii_letters).lower() @@ -118,6 +124,9 @@ class _TagData: self.inlined = bool(tag.inlined) if self.super \ and hasattr(tag, 'inlined') and bool(tag.inlined) else False + self.noinline = bool(tag.noinline) if self.type == self.BLOCK \ + and hasattr(tag, 'noinline') else False + # Content processing utilities. # `last` is the content of the tag. A boolean indicates that we # only want to know if the content is empty or not, and a string @@ -143,7 +152,7 @@ class _TagData: self.last = "" def __repr__(self): - return '<TagData tag=' + repr(self.tag) + '>' + return f'TagData(tag = {repr(self.tag)})' # --- # Translator main class. @@ -633,8 +642,9 @@ class Translator: # Then, put the tag beginnings. to_begin = superblocks \ - + ([block_to_start] if block_to_start else []) \ - + inlines + + ([block_to_start] if block_to_start else []) + if all(not x.noinline for x in to_begin): + to_begin += inlines for dat in to_begin: if dat.started: |