X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/3a0c83394d5783715fab2be29fa1a9cfc3574e28..23d025c8875cca1404f274aca7170c9db5e980e7:/src/librarian/builders/txt.py?ds=inline diff --git a/src/librarian/builders/txt.py b/src/librarian/builders/txt.py index 8302de5..69ddbe2 100644 --- a/src/librarian/builders/txt.py +++ b/src/librarian/builders/txt.py @@ -15,14 +15,6 @@ class TxtFragment: self.current_margin = 0 self.starting_block = True - def push_legacy_margin(self, margin): - if margin: - if self.pieces: - self.pieces[-1] = self.pieces[-1].rstrip(' ') - self.pieces.append('\r\n' * margin) - self.current_margin += margin - self.starting_block = True - def push_margin(self, margin): if margin: if self.pieces: @@ -45,10 +37,14 @@ class TxtFragment: class TxtBuilder: """ """ + build_method_fn = 'txt_build' file_extension = "txt" identifier = "txt" + after_child_fn = 'txt_after_child' + debug = False orphans = False + normalize_whitespace = True default_license_description = { "pol": ( @@ -107,9 +103,6 @@ class TxtBuilder: def push_margin(self, margin): self.current_fragments[-1].push_margin(margin) - def push_legacy_margin(self, margin, where=None): - self.current_fragments[-1].push_legacy_margin(margin) - def build(self, document, raw_text=False, **kwargs): document.tree.getroot().txt_build(self) meta = document.meta @@ -123,27 +116,26 @@ class TxtBuilder: for translator in meta.translators ) ) - #builder.push_margin(2) - self.push_legacy_margin(1) + self.push_margin(2) if meta.isbn_txt: - #builder.push_margin(2) - self.push_legacy_margin(1) + self.push_margin(2) isbn = meta.isbn_txt if isbn.startswith(('ISBN-' , 'ISBN ')): isbn = isbn[5:] self.push_text('ISBN {isbn}'.format(isbn=isbn)) #builder.push_margin(5) - #builder.push_margin(4) - self.push_legacy_margin(1) + self.push_margin(4) self.exit_fragment() - text = ''.join(self.fragments['header'].pieces) + ''.join(self.fragments[None].pieces) + text = ''.join(self.fragments[None].pieces).lstrip() if raw_text: result = text else: + text = ''.join(self.fragments['header'].pieces) + text + if meta.license: license_description = self.license_description['pol'].format(meta=meta) else: