add mode to tex formatters

This commit is contained in:
Maximilian Keßler 2022-02-09 19:25:25 +01:00
parent e84030978c
commit 12a89f9560
2 changed files with 11 additions and 1 deletions

View file

@ -3,6 +3,13 @@ from enum import Enum
from typing import Optional
class FormatterMode(Enum):
normal = 0
drop = 1
macrocode = 2
macrocode_drop = 3
class NamingScheme(Enum):
prepend_author = 'prepend_author'
clean = 'clean'

View file

@ -5,6 +5,7 @@ from abc import ABC, abstractmethod
from .formatting_config import FormattingConfig
from .macros import Macro
from .pytex_formatter import PyTeXFormatter
from .enums import *
class LineStream:
@ -61,6 +62,7 @@ class TexFormatter(PyTeXFormatter, ABC):
super().__init__(*args, **kwargs)
self._macros: List[Macro] = []
self._line_stream: Optional[LineStream] = None
self._mode = FormatterMode.normal
def open_output_stream(self, build_dir: Path, filename: str) -> None:
"""
@ -127,7 +129,8 @@ class TexFormatter(PyTeXFormatter, ABC):
def write_line(self, line: str):
if self._output_file is None:
raise NotImplementedError
self._output_file.write(line)
if not self._mode == FormatterMode.drop or self._mode == FormatterMode.macrocode_drop:
self._output_file.write(line)
def format_pre_header(self) -> None:
pass