add header in tex formatter

This commit is contained in:
Maximilian Keßler 2022-02-06 18:51:49 +01:00
parent 94516b4bbb
commit 79fc7b5217
3 changed files with 19 additions and 4 deletions

View file

@ -51,7 +51,7 @@ class DictFormatter(PyTeXFormatter):
def format(self, build_dir: Path, overwrite: bool = False) -> Optional[List[Tuple[str, Dict]]]:
build_dir.mkdir(parents=True, exist_ok=True)
self.format_header()
self.make_header()
for language in self._languages:
lines = [self.header, '']
lines += r'\ProvidesDictionary{{{dict_name}}}{{{language}}}'.format(

View file

@ -116,7 +116,7 @@ class PyTeXFormatter(FormatterIF):
return self._header
def format_header(self, **kwargs) -> str:
def make_header(self, **kwargs) -> str:
return '\n'.join(
[
'%'*80,

View file

@ -93,8 +93,16 @@ class TexFormatter(PyTeXFormatter):
def future_config(self) -> Optional[List[Tuple[str, Dict]]]:
raise NotImplementedError
def format(self, build_dir: Path, overwrite: bool = False) -> Optional[List[Tuple[str, Dict]]]:
self.open_output_stream()
def format_pre_header(self) -> None:
pass
def format_header(self):
self._output_file.write(self.make_header())
def format_post_header(self) -> None:
pass
def format_document(self) -> None:
while not self.line_stream.exhausted:
recent_replacement = True
while recent_replacement:
@ -105,5 +113,12 @@ class TexFormatter(PyTeXFormatter):
recent_replacement = True
break
self._shipout_line()
def format(self, build_dir: Path, overwrite: bool = False) -> Optional[List[Tuple[str, Dict]]]:
self.open_output_stream()
self.format_pre_header()
self.format_header()
self.format_post_header()
self.format_document()
self._output_file.close()
return self.future_config