From 3734339fee49d463211f0ca67dfb316d3f30181d Mon Sep 17 00:00:00 2001
From: kaldan007
Date: Tue, 16 Mar 2021 15:15:08 +0530
Subject: [PATCH 1/4] fix: toc level variable changed
---
openpecha/serializers/epub.py | 22 ++++++++++++----------
tests/integration/test_tsadra.py | 22 +++++-----------------
2 files changed, 17 insertions(+), 27 deletions(-)
diff --git a/openpecha/serializers/epub.py b/openpecha/serializers/epub.py
index ea925d34..f23b4410 100644
--- a/openpecha/serializers/epub.py
+++ b/openpecha/serializers/epub.py
@@ -36,6 +36,13 @@ class Tsadra_template:
footnote_EP = ""
footnote_reference_SP = '
\n'
- only_start_ann = True
elif ann["type"] == AnnType.error_candidate:
start_payload = "["
end_payload = "]"
@@ -277,6 +273,14 @@ def get_footnote_references(self, footnotes):
footnote_references += f'{p_tag}{Tsadra_template.footnote_reference_SP} id="fr{footnote_id}">{footnote["footnote_ref"]}'
return footnote_references
+ def add_credit_page(self, result):
+ author_pat = re.search('.+
', result)
+ credit_pg_name = self.meta["source_metadata"].get("credit", "")
+ if credit_pg_name:
+ credit_page_pat = f'{author_pat[0]}\n{Tsadra_template.credit_page_SP}
\n'
+ result = re.sub(author_pat[0], credit_page_pat, result, 1)
+ return result
+
def serialize(self, toc_levels={}, output_path="./output/epub_output"):
"""This module serialize .opf file to other format such as .epub etc. In case of epub,
we are using calibre ebook-convert command to do the conversion by passing our custom css template
@@ -297,6 +301,7 @@ def serialize(self, toc_levels={}, output_path="./output/epub_output"):
results = self.get_result()
for vol_id, result in results.items():
+ result = self.add_credit_page(result)
footnote_ref_tag = ""
if "Footnote" in self.layers:
footnote_fn = self.opf_path / "layers" / vol_id / "Footnote.yml"
diff --git a/tests/integration/test_tsadra.py b/tests/integration/test_tsadra.py
index 5215957b..831319b2 100644
--- a/tests/integration/test_tsadra.py
+++ b/tests/integration/test_tsadra.py
@@ -9,7 +9,7 @@
pecha_name = f"P{pecha_id:06}"
ebook_path = f"./tests/data/serialize/tsadra/src/{pecha_name}/OEBPS/"
opfs_path = "./tests/data/serialize/tsadra"
- opf_path = f"./tests/data/serialize/tsadra/{pecha_name}.opf/"
+ opf_path = f"./tests/data/serialize/tsadra/{pecha_name}/{pecha_name}.opf/"
hfml_path = "./output/demo/output/P000113_hfml/"
ebook_output_path = "./tests/data/serialize/tsadra/ebook"
From 0342a179862aa663fe38059290bf67332bb3f1e8 Mon Sep 17 00:00:00 2001
From: kaldan007
Date: Thu, 18 Mar 2021 12:06:16 +0530
Subject: [PATCH 4/4] fix(epub-serializer): removed credit page layer n added
credit page img tag after first author
---
tests/test_formatter.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/tests/test_formatter.py b/tests/test_formatter.py
index 8c964dc3..45108f26 100644
--- a/tests/test_formatter.py
+++ b/tests/test_formatter.py
@@ -307,7 +307,6 @@ def test_tsadra_formatter(self):
expected_result = {
AnnType.book_title: [[(None, {"span": {"start": 0, "end": 84}})]],
AnnType.sub_title: [[]],
- AnnType.credit_page: [[]],
AnnType.book_number: [[]],
AnnType.poti_title: [[]],
AnnType.author: [