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:
parent
9eb7399536
commit
c2aec7add6
4 changed files with 39 additions and 7 deletions
|
|
@ -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'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue