diff --git a/PyTeX/format/simple_tex_formatter.py b/PyTeX/format/simple_tex_formatter.py index 64bae86..d42b650 100644 --- a/PyTeX/format/simple_tex_formatter.py +++ b/PyTeX/format/simple_tex_formatter.py @@ -37,25 +37,4 @@ class SimpleTeXFormatter(TexFormatter): return line.rstrip() def format_post_header(self) -> None: - if self.config.has_description: - if self.config.tex_flavour == TeXFlavour.LaTeX2e: - self._shipout_line( - r'\Provides%s{%s}[%s - %s]' - % ( - self.config.tex_type.value.capitalize(), - self.name, - self.attribute_dict[FormatterProperty.date.value], - self.attribute_dict[FormatterProperty.description.value] - ) - ) - else: - self._shipout_line( - '\\ProvidesExpl%s { %s } { %s } { %s }\n { %s }' - % ( - self.config.tex_type.value.capitalize(), - self.name, - self.attribute_dict[FormatterProperty.date.value], - self.config.version, - self.config.description - ) - ) + self._shipout_line(self._get_provides_text()) diff --git a/PyTeX/format/tex_formatter.py b/PyTeX/format/tex_formatter.py index ac78a65..f2cb82b 100644 --- a/PyTeX/format/tex_formatter.py +++ b/PyTeX/format/tex_formatter.py @@ -143,6 +143,29 @@ class TexFormatter(PyTeXFormatter, ABC): def mode(self, mode: FormatterMode) -> None: self._mode = mode + def _get_provides_text(self) -> str: + if self.config.has_description: + if self.config.tex_flavour == TeXFlavour.LaTeX2e: + return \ + r'\Provides%s{%s}[%s - %s]' \ + % ( + self.config.tex_type.value.capitalize(), + self.name, + self.attribute_dict[FormatterProperty.date.value], + self.attribute_dict[FormatterProperty.description.value] + ) + + else: + return \ + '\\ProvidesExpl%s { %s } { %s } { %s }\n { %s }' \ + % ( + self.config.tex_type.value.capitalize(), + self.name, + self.attribute_dict[FormatterProperty.date.value], + self.config.version, + self.config.description + ) + def format_header(self): if self._output_file is None: raise NotImplementedError