diff --git a/src/methods/aggregateDetails.ts b/src/methods/aggregateDetails.ts index 63a994a..0d24a53 100644 --- a/src/methods/aggregateDetails.ts +++ b/src/methods/aggregateDetails.ts @@ -27,9 +27,9 @@ export const aggregateBookAndHighlightDetails = async (): Promise { return { chapter: annotation.ZFUTUREPROOFING5, - contextualText: annotation.ZANNOTATIONREPRESENTATIVETEXT, - highlight: annotation.ZANNOTATIONSELECTEDTEXT, - note: annotation.ZANNOTATIONNOTE, + contextualText: preserveNewlineIndentation(annotation.ZANNOTATIONREPRESENTATIVETEXT), + highlight: preserveNewlineIndentation(annotation.ZANNOTATIONSELECTEDTEXT), + note: preserveNewlineIndentation(annotation.ZANNOTATIONNOTE), highlightStyle: annotation.ZANNOTATIONSTYLE, highlightCreationDate: annotation.ZANNOTATIONCREATIONDATE, highlightModificationDate: annotation.ZANNOTATIONMODIFICATIONDATE @@ -43,3 +43,8 @@ export const aggregateBookAndHighlightDetails = async (): Promise { + return text.replace(/\n\n/g, '
\n'); +} diff --git a/test/mocks/aggregatedDetailsData.ts b/test/mocks/aggregatedDetailsData.ts index 882cf07..05df178 100644 --- a/test/mocks/aggregatedDetailsData.ts +++ b/test/mocks/aggregatedDetailsData.ts @@ -18,6 +18,16 @@ export const annotationsToAggregate = [{ "ZANNOTATIONMODIFICATIONDATE": 731876693.002279, "ZANNOTATIONSTYLE": 3, "ZANNOTATIONDELETED": 0 +}, { + "ZANNOTATIONASSETID": "THBFYNJKTGFTTVCGSAE5", + "ZFUTUREPROOFING5": "Another aggregated Introduction", + "ZANNOTATIONREPRESENTATIVETEXT": "This is a contextual text for the aggregated hightlight from the Apple iPhone User Guide\n\ncontaining a new line to test the preservation of indentation", + "ZANNOTATIONSELECTEDTEXT": "aggregated hightlight from the Apple iPhone User Guide\n\ncontaining a new line to test the preservation of indentation", + "ZANNOTATIONNOTE": "Test note for the aggregated hightlight from the Apple iPhone User Guide\n\nalong with a new line to test the preservation of indentation", + "ZANNOTATIONCREATIONDATE": 731876693.002279, + "ZANNOTATIONMODIFICATIONDATE": 731876693.002279, + "ZANNOTATIONSTYLE": 3, + "ZANNOTATIONDELETED": 0 }]; export const aggregatedHighlights = [{ @@ -36,5 +46,13 @@ export const aggregatedHighlights = [{ "highlightStyle": 3, "highlightCreationDate": 731876693.002279, "highlightModificationDate": 731876693.002279 + }, { + "chapter": "Another aggregated Introduction", + "contextualText": "This is a contextual text for the aggregated hightlight from the Apple iPhone User Guide
\ncontaining a new line to test the preservation of indentation", + "highlight": "aggregated hightlight from the Apple iPhone User Guide
\ncontaining a new line to test the preservation of indentation", + "note": "Test note for the aggregated hightlight from the Apple iPhone User Guide
\nalong with a new line to test the preservation of indentation", + "highlightStyle": 3, + "highlightCreationDate": 731876693.002279, + "highlightModificationDate": 731876693.002279 }] }]; diff --git a/test/mocks/renderedTemplate.ts b/test/mocks/renderedTemplate.ts index adec8ee..85b2274 100644 --- a/test/mocks/renderedTemplate.ts +++ b/test/mocks/renderedTemplate.ts @@ -4,7 +4,7 @@ Link:: [Apple Books Link](ibooks://assetid/THBFYNJKTGFTTVCGSAE5) ## Annotations -Number of annotations:: 1 +Number of annotations:: 2 ---- @@ -13,6 +13,16 @@ Number of annotations:: 1 - 🎯 Highlight:: aggregated hightlight from the Apple iPhone User Guide - 📝 Note:: Test note for the aggregated hightlight from the Apple iPhone User Guide +---- + +- 📖 Chapter:: Another aggregated Introduction +- 🔖 Context:: This is a contextual text for the aggregated hightlight from the Apple iPhone User Guide
+containing a new line to test the preservation of indentation +- 🎯 Highlight:: aggregated hightlight from the Apple iPhone User Guide
+containing a new line to test the preservation of indentation +- 📝 Note:: Test note for the aggregated hightlight from the Apple iPhone User Guide
+along with a new line to test the preservation of indentation + `; export const renderedCustomTemplateMock = `Title:: 📕 Apple iPhone - User Guide - Instructions - with - restricted - symbols - in - title @@ -26,7 +36,7 @@ Link:: [Apple Books Link](ibooks://assetid/THBFYNJKTGFTTVCGSAE5) ## Annotations -Number of annotations:: 1 +Number of annotations:: 2 ---- @@ -37,4 +47,16 @@ Number of annotations:: 1 - 📅 Highlight taken on:: 2024-03-11 03:04:53 PM -04:00 - 📅 Highlight modified on:: 2024-03-11 03:04:53 PM -04:00 +---- + +- 📖 Chapter:: Another aggregated Introduction +- 🔖 Context:: This is a contextual text for the aggregated hightlight from the Apple iPhone User Guide
+containing a new line to test the preservation of indentation +- 🎯 Highlight:: aggregated hightlight from the Apple iPhone User Guide
+containing a new line to test the preservation of indentation
+- 📝 Note:: Test note for the aggregated hightlight from the Apple iPhone User Guide
+along with a new line to test the preservation of indentation +- 📅 Highlight taken on:: 2024-03-11 03:04:53 PM -04:00 +- 📅 Highlight modified on:: 2024-03-11 03:04:53 PM -04:00 + `; diff --git a/test/mocks/testDatabase.sqlite b/test/mocks/testDatabase.sqlite index c7cfef2..5d46038 100644 Binary files a/test/mocks/testDatabase.sqlite and b/test/mocks/testDatabase.sqlite differ