From f65610c06bd67463ed04a90b1314fd1a074845b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Thu, 17 Feb 2022 21:44:34 +0100 Subject: [PATCH] make padding in generic text optional --- PyTeX/format/dtx_formatter.py | 4 +++- PyTeX/format/generic_text.py | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/PyTeX/format/dtx_formatter.py b/PyTeX/format/dtx_formatter.py index 7d4441d..4d2bc25 100644 --- a/PyTeX/format/dtx_formatter.py +++ b/PyTeX/format/dtx_formatter.py @@ -36,7 +36,8 @@ class DTXFormatter(TexFormatter): outfile=self.name + switcher[self.config.tex_out_type], preamble='', # TODO postamble='', # TODO - guards=', '.join(self.config.docstrip_guards) + guards=', '.join(self.config.docstrip_guards), + padding=False ) def _get_drv_file(self) -> str: @@ -45,6 +46,7 @@ class DTXFormatter(TexFormatter): documentclass='l3doc', # TODO preamble='', # TODO infile=self.name + '.dtx', + padding=False ) def format_pre_header(self) -> None: diff --git a/PyTeX/format/generic_text.py b/PyTeX/format/generic_text.py index 89bf78a..8e36452 100644 --- a/PyTeX/format/generic_text.py +++ b/PyTeX/format/generic_text.py @@ -62,10 +62,16 @@ class GenericText: return str(self._path) if self._path else None def format(self, **kwargs) -> str: + padding = True + if 'padding' in kwargs.keys(): + padding = kwargs['padding'] + kwargs.pop('padding', None) lines = [] for line in self.text: try: - line = '% ' + line.rstrip().format(**kwargs).ljust(77) + '%' + line = '% ' + line.rstrip().format(**kwargs) + if padding: + line = line.ljust(77) + ' %' if len(line) > 80: logger.warning( 'Line too long') # TODO