X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/3a0c83394d5783715fab2be29fa1a9cfc3574e28..b13f09caed970090efa8a6c7205d71cc82ff6c97:/src/librarian/builders/epub.py diff --git a/src/librarian/builders/epub.py b/src/librarian/builders/epub.py index 8f21879..e009d4a 100644 --- a/src/librarian/builders/epub.py +++ b/src/librarian/builders/epub.py @@ -4,6 +4,7 @@ from datetime import date import io import os +import re import tempfile from ebooklib import epub from lxml import etree @@ -80,9 +81,11 @@ class EpubBuilder(Builder): isbn_field = 'isbn_epub' orphans = True - def __init__(self, *args, **kwargs): + def __init__(self, *args, debug=False, **kwargs): self.chars = set() self.fundr = 0 + self.debug = debug + self.splits = [] super().__init__(*args, **kwargs) def build(self, document, **kwargs): @@ -707,3 +710,8 @@ class EpubBuilder(Builder): file_name=name ) return name + + def process_comment(self, comment): + m = re.match(r'TRIM:(\d+)', comment.text) + if m is not None: + self.splits.append(comment.sourceline - int(m.group(1)))