fix some formatting issues with headers

This commit is contained in:
Maximilian Keßler 2022-02-09 16:24:02 +01:00
parent 190ff1a339
commit 1f9825e937
2 changed files with 19 additions and 13 deletions

View file

@ -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,6 +96,9 @@ class GenericText:
def __iadd__(self, other: Union[None, GenericText, List[str]]) -> GenericText:
if not self.has_value():
if isinstance(other, GenericText):
self.text = other.text
else:
self.text = other
elif isinstance(other, GenericText):
if other.has_value():

View file

@ -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:
try:
return '\n'.join(
[
'%' * 80,
self.header.format(**kwargs), # TODO: add standard keywords here
self.header.format(**self.attribute_dict),
'%' * 80,
''
]
)
except KeyError:
raise NotImplementedError