Improve default annotation formatting

This commit is contained in:
Marty Oehme 2022-12-23 00:42:23 +01:00
parent 59ff74475d
commit 999a4c88cc
Signed by: Marty
GPG key ID: 73BA40D5AFAF49C9

View file

@ -49,7 +49,7 @@ class ExtractPlugin(PapersPlugin):
.get("extract", {}) .get("extract", {})
.get( .get(
"formatting", "formatting",
"[{page}]{newline}{quote_begin}> {quote}{newline}{quote_end}{note_begin}Note: {note}{note_end}", "{newline}{quote_begin}> {quote} {quote_end}[{page}]{note_begin}{newline}Note: {note}{note_end}",
) )
) )
@ -151,10 +151,10 @@ class ExtractPlugin(PapersPlugin):
def _format_annotation(self, quote, note, pagenumber=0): def _format_annotation(self, quote, note, pagenumber=0):
output = self.formatting output = self.formatting
replacements = { replacements = {
"{quote}": quote, r"{quote}": quote,
"{note}": note, r"{note}": note,
"{page}": str(pagenumber), r"{page}": str(pagenumber),
"{newline}": "\n", r"{newline}": "\n",
} }
if note == "": if note == "":
output = re.sub(r"{note_begin}.*{note_end}", "", output) output = re.sub(r"{note_begin}.*{note_end}", "", output)
@ -243,7 +243,7 @@ class ExtractPlugin(PapersPlugin):
""" """
output = "# Annotations\n\n" output = "# Annotations\n\n"
for annotation in annotations: for annotation in annotations:
output += f"> {annotation}\n\n" output += f"{annotation}\n\n"
write_file(notepath, output, "w") write_file(notepath, output, "w")
def _append_to_note(self, notepath, annotations): def _append_to_note(self, notepath, annotations):
@ -260,7 +260,7 @@ class ExtractPlugin(PapersPlugin):
output = "" output = ""
for annotation in existing_dropped: for annotation in existing_dropped:
output += f"> {annotation}\n\n" output += f"{annotation}\n\n"
write_file(notepath, output, "a") write_file(notepath, output, "a")