feat: Notify formatters if formatting first entry

This allows headers to be created by a formatter, which will
*only* be added to the very first entry created and not to
each entry. Currently for example this is used to create
a csv header but not for each document in turn.
This commit is contained in:
Marty Oehme 2024-06-12 11:45:35 +02:00
parent 9eb7399536
commit c2aec7add6
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
4 changed files with 39 additions and 7 deletions

View file

@ -54,6 +54,15 @@ def test_count_default():
def test_csv_default():
fmt = format_csv
assert fmt(document, annotations) == (
'Highlight,,0,"my lovely text","","document-author",'
'"document-title","","myfile.pdf"\n'
'Highlight,,0,"my second text","with note","document-author",'
'"document-title","","myfile.pdf"'
)
def test_csv_with_header():
fmt = format_csv
assert fmt(document, annotations, first=True) == (
"type,tag,page,quote,note,author,title,ref,file\n"
'Highlight,,0,"my lovely text","","document-author",'
'"document-title","","myfile.pdf"\n'