X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/3a0c83394d5783715fab2be29fa1a9cfc3574e28..refs/heads/master:/src/librarian/builders/epub.py?ds=sidebyside diff --git a/src/librarian/builders/epub.py b/src/librarian/builders/epub.py index 8f21879..3ef95f4 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 @@ -76,13 +77,16 @@ class Builder: class EpubBuilder(Builder): + build_method_fn = 'epub_build' file_extension = 'epub' 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 +711,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)))