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
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
|
class FormatterMode(Enum):
|
||||||
|
normal = 0
|
||||||
|
drop = 1
|
||||||
|
macrocode = 2
|
||||||
|
macrocode_drop = 3
|
||||||
|
|
||||||
|
|
||||||
class NamingScheme(Enum):
|
class NamingScheme(Enum):
|
||||||
prepend_author = 'prepend_author'
|
prepend_author = 'prepend_author'
|
||||||
clean = 'clean'
|
clean = 'clean'
|
||||||
|
|
|
@ -5,6 +5,7 @@ from abc import ABC, abstractmethod
|
||||||
from .formatting_config import FormattingConfig
|
from .formatting_config import FormattingConfig
|
||||||
from .macros import Macro
|
from .macros import Macro
|
||||||
from .pytex_formatter import PyTeXFormatter
|
from .pytex_formatter import PyTeXFormatter
|
||||||
|
from .enums import *
|
||||||
|
|
||||||
|
|
||||||
class LineStream:
|
class LineStream:
|
||||||
|
@ -61,6 +62,7 @@ class TexFormatter(PyTeXFormatter, ABC):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._macros: List[Macro] = []
|
self._macros: List[Macro] = []
|
||||||
self._line_stream: Optional[LineStream] = None
|
self._line_stream: Optional[LineStream] = None
|
||||||
|
self._mode = FormatterMode.normal
|
||||||
|
|
||||||
def open_output_stream(self, build_dir: Path, filename: str) -> None:
|
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):
|
def write_line(self, line: str):
|
||||||
if self._output_file is None:
|
if self._output_file is None:
|
||||||
raise NotImplementedError
|
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:
|
def format_pre_header(self) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in a new issue