add mode to tex formatters
This commit is contained in:
parent
e84030978c
commit
12a89f9560
2 changed files with 11 additions and 1 deletions
|
@ -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'
|
||||
|
|
|
@ -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,6 +129,7 @@ class TexFormatter(PyTeXFormatter, ABC):
|
|||
def write_line(self, line: str):
|
||||
if self._output_file is None:
|
||||
raise NotImplementedError
|
||||
if not self._mode == FormatterMode.drop or self._mode == FormatterMode.macrocode_drop:
|
||||
self._output_file.write(line)
|
||||
|
||||
def format_pre_header(self) -> None:
|
||||
|
|
Loading…
Reference in a new issue