add header to simple tex formatter

This commit is contained in:
Maximilian Keßler 2022-02-09 19:50:49 +01:00
parent e760eaef6d
commit 8e115b46c2
3 changed files with 27 additions and 2 deletions

View file

@ -111,6 +111,7 @@ class FormatterProperty(MacroReplacementAtomIF, Enum):
pytex_dirty = 'pytex_dirty' pytex_dirty = 'pytex_dirty'
tex_type = 'tex_type' tex_type = 'tex_type'
tex_flavour = 'latex_flavour' tex_flavour = 'latex_flavour'
description = 'description'
class Argument(MacroReplacementAtomIF, Enum): class Argument(MacroReplacementAtomIF, Enum):

View file

@ -152,7 +152,8 @@ class PyTeXFormatter(FormatterIF, ABC):
FormatterProperty.pytex_dirty.value: self.git_version_info.pytex_version.dirty, FormatterProperty.pytex_dirty.value: self.git_version_info.pytex_version.dirty,
FormatterProperty.tex_type.value: self.config.tex_type.value, FormatterProperty.tex_type.value: self.config.tex_type.value,
FormatterProperty.tex_flavour.value: self.config.tex_flavour.value, FormatterProperty.tex_flavour.value: self.config.tex_flavour.value,
FormatterProperty.file_prefix.value: self.file_prefix FormatterProperty.file_prefix.value: self.file_prefix,
FormatterProperty.description.value: self.config.description
} }
@property @property

View file

@ -2,7 +2,7 @@ from .formatting_config import FormattingConfig
from .tex_formatter import TexFormatter from .tex_formatter import TexFormatter
from pathlib import Path from pathlib import Path
from typing import Optional, List, Tuple, Dict from typing import Optional, List, Tuple, Dict
from .enums import TeXFlavour, TeXType from .enums import TeXFlavour, TeXType, FormatterProperty
class SimpleTeXFormatter(TexFormatter): class SimpleTeXFormatter(TexFormatter):
@ -35,3 +35,26 @@ class SimpleTeXFormatter(TexFormatter):
return '' if raw == '' else raw + '%' return '' if raw == '' else raw + '%'
else: else:
return line.rstrip() return line.rstrip()
def format_post_header(self) -> None:
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(
r'\ProvidesExpl%s{%s}{%s}{%s}{%s}'
% (
self.config.tex_type.value.capitalize(),
self.name,
self.config.version,
self.attribute_dict[FormatterProperty.date.value],
self.config.description
)
)