diff --git a/PyTeX/format/generic_text.py b/PyTeX/format/generic_text.py index 27a9d72..89bf78a 100644 --- a/PyTeX/format/generic_text.py +++ b/PyTeX/format/generic_text.py @@ -65,7 +65,7 @@ class GenericText: lines = [] for line in self.text: try: - line = '% ' + line.format(**kwargs).rjust(77) + '%' + line = '% ' + line.rstrip().format(**kwargs).ljust(77) + '%' if len(line) > 80: logger.warning( 'Line too long') # TODO @@ -96,7 +96,10 @@ class GenericText: def __iadd__(self, other: Union[None, GenericText, List[str]]) -> GenericText: if not self.has_value(): - self.text = other + if isinstance(other, GenericText): + self.text = other.text + else: + self.text = other elif isinstance(other, GenericText): if other.has_value(): self.text += other.text diff --git a/PyTeX/format/pytex_formatter.py b/PyTeX/format/pytex_formatter.py index 48cdba9..fa1bcfd 100644 --- a/PyTeX/format/pytex_formatter.py +++ b/PyTeX/format/pytex_formatter.py @@ -149,9 +149,9 @@ class PyTeXFormatter(FormatterIF, ABC): FormatterProperty.pytex_branch.value: self.git_version_info.pytex_version.branch, FormatterProperty.pytex_commit.value: self.git_version_info.pytex_version.commit_hash, FormatterProperty.pytex_dirty.value: self.git_version_info.pytex_version.dirty, - FormatterProperty.tex_type.value: str(self.config.tex_type), - FormatterProperty.tex_flavour.value: str(self.config.tex_flavour), - FormatterProperty.file_prefix.value: str(self.file_prefix) + FormatterProperty.tex_type.value: self.config.tex_type.value, + FormatterProperty.tex_flavour.value: self.config.tex_flavour.value, + FormatterProperty.file_prefix.value: self.file_prefix } @property @@ -199,11 +199,14 @@ class PyTeXFormatter(FormatterIF, ABC): return self._output_file.name def make_header(self, **kwargs) -> str: - return '\n'.join( - [ - '%' * 80, - self.header.format(**kwargs), # TODO: add standard keywords here - '%' * 80, - '' - ] - ) + try: + return '\n'.join( + [ + '%' * 80, + self.header.format(**self.attribute_dict), + '%' * 80, + '' + ] + ) + except KeyError: + raise NotImplementedError