Refactor highlight prefix setting

This commit is contained in:
Marty Oehme 2022-12-22 23:01:14 +01:00
parent b65c2a3be6
commit e255405d96
Signed by: Marty
GPG key ID: 73BA40D5AFAF49C9

View file

@ -136,7 +136,7 @@ class ExtractPlugin(PapersPlugin):
annotations.append(f"[{(page.number or 0) + 1}] {content}") annotations.append(f"[{(page.number or 0) + 1}] {content}")
return annotations return annotations
def _retrieve_annotation_content(self, page, annotation, connector = "\nNote: "): def _retrieve_annotation_content(self, page, annotation, highlight_prefix = "> ", note_prefix = "Note: "):
"""Gets the text content of an annotation. """Gets the text content of an annotation.
Returns the actual content of an annotation. Sometimes Returns the actual content of an annotation. Sometimes
@ -150,15 +150,15 @@ class ExtractPlugin(PapersPlugin):
# highlight with selection in note # highlight with selection in note
if Levenshtein.ratio(content,written) > self.minimum_similarity: if Levenshtein.ratio(content,written) > self.minimum_similarity:
return content return f"{highlight_prefix}{content}"
# an independent note, not a highlight # an independent note, not a highlight
elif content and not written: elif content and not written:
return content return f"{note_prefix}{content}"
# both a highlight and a note # both a highlight and a note
elif content: elif content:
return f"{written}{connector}{content}" return f"{highlight_prefix}{written}\n{note_prefix}{content}"
# highlight with selection not in note # highlight with selection not in note
return written return f"{highlight_prefix}{written}"
def _to_stdout(self, annotated_papers): def _to_stdout(self, annotated_papers):
"""Write annotations to stdout. """Write annotations to stdout.
@ -173,7 +173,7 @@ class ExtractPlugin(PapersPlugin):
if annotations: if annotations:
output += f"{paper.citekey}\n" output += f"{paper.citekey}\n"
for annot in annotations: for annot in annotations:
output += f'> "{annot}"\n' output += f'{annot}\n\n'
output += "\n" output += "\n"
print(output) print(output)