From 95ef1423d4e53d4cce5679949ee5a1588593f4a8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 15 Mar 2021 11:43:46 +0530 Subject: [PATCH] start_cfi startswith / so dont create a double slash Also fix tests for highlight sorting --- src/pyj/read_book/annotations.pyj | 2 +- src/pyj/test_annotations.pyj | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pyj/read_book/annotations.pyj b/src/pyj/read_book/annotations.pyj index 72e347a59c..e182eb59c7 100644 --- a/src/pyj/read_book/annotations.pyj +++ b/src/pyj/read_book/annotations.pyj @@ -20,7 +20,7 @@ def highlight_get_cfi(hl): cfi = hl.start_cfi if cfi: si = f'/{hl.spine_index}' if hl.spine_index? else no_cfi - return f'{si}/{cfi}' + return f'{si}{cfi}' return no_cfi diff --git a/src/pyj/test_annotations.pyj b/src/pyj/test_annotations.pyj index 651678445c..9b7d76ca41 100644 --- a/src/pyj/test_annotations.pyj +++ b/src/pyj/test_annotations.pyj @@ -8,15 +8,15 @@ from testing import assert_equal, test, assert_true def bm(title, bmid, year=20, first_cfi_number=1): return { - 'title': title, 'id': bmid, 'timestamp': str.format('20{}-06-29T03:21:48.895323+00:00', year), + 'title': title, 'id': bmid, 'timestamp': f'20{year}-06-29T03:21:48.895323+00:00', 'pos_type': 'epubcfi', 'pos': str.format('epubcfi(/{}/4/8)', first_cfi_number) } def hl(uuid, hlid, year=20, first_cfi_number=1): return { - 'uuid': uuid, 'id': hlid, 'timestamp': str.format('20{}-06-29T03:21:48.895323+00:00', year), - 'start_cfi': str.format('epubcfi(/{}/4/8)', first_cfi_number) + 'uuid': uuid, 'id': hlid, 'timestamp': f'20{year}-06-29T03:21:48.895323+00:00', + 'start_cfi': '/4/8', 'spine_index': first_cfi_number }