From a5910f50f38adeef3d9b1cfce6d9934dc81ab7b9 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 22 Dec 2022 18:33:00 +0100 Subject: [PATCH] Add writing annotations to notes --- extract/extract.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/extract/extract.py b/extract/extract.py index 8b74600..a265f11 100644 --- a/extract/extract.py +++ b/extract/extract.py @@ -109,12 +109,19 @@ class ExtractPlugin(PapersPlugin): print(f'> "{annot}"') print("") - - def to_notes(self, filename, annotations): - with open(f"{os.path.splitext(filename)[0]}.md", "w") as out: - out.write(f"# Annotations:\n\n") - out.writelines(annotations) - out.write(f"\n---") + def to_notes(self, conf, annotated_papers, edit=False): + for contents in annotated_papers: + paper = contents[0] + annotations = contents[1] + if annotations: + notepath = self.broker.real_notepath( + paper.citekey, conf["main"]["note_extension"] + ) + output = "# Annotations\n\n" + for annotation in annotations: + output+=f"> {annotation}\n\n" + write_file(notepath, output, 'w') + # TODO implement NoteEvent(citekey).send() @PaperChangeEvent.listen()