Add configurable note and quote prefixes

This commit is contained in:
Marty Oehme 2022-12-22 23:09:43 +01:00
parent f103cc51b5
commit 8f01b93de2
Signed by: Marty
GPG Key ID: 73BA40D5AFAF49C9
2 changed files with 12 additions and 1 deletions

View File

@ -20,12 +20,21 @@ active = extract
[[extract]]
on_import = False
quote_prefix = "> "
note_prefix = "Note: "
minimum_similarity = 0.75
```
If `on_import` is `True` extraction is automatically run whenever a new document is added to the library,
if false extraction has to be handled manually.
`quote_prefix` and `note_prefix` define what is put in front of the quoted part of an annotation and the annotator's own notes respectively, so that ultimately a note (by default) looks like this:
```markdown
[4] > came “urban rights” caused collective outrage. Thus, through- out 2007 and 2008, protestors in towns and villages across the Nile Delta poured into the streets to rally over cuts in water flow. Deployment of massive riot police could not stop
Note: Often illegally connected to network, revolution of the thirsty
```
`minimum_similarity` sets the required similarity of an annotation's note and written words to be viewed
as one. Any annotation that has both and is *under* the minimum similarity will be added in the following form:

View File

@ -41,6 +41,8 @@ class ExtractPlugin(PapersPlugin):
# and so on
self.on_import = conf["plugins"].get("extract", {}).get("on_import", False)
self.minimum_similarity = float(conf["plugins"].get("extract", {}).get("minimum_similarity", 0.75))
self.highlight_prefix = conf["plugins"].get("extract", {}).get("quote_prefix", "> ")
self.note_prefix = conf["plugins"].get("extract", {}).get("note_prefix", "Note: ")
def update_parser(self, subparsers, conf):
"""Allow the usage of the pubs extract subcommand"""
@ -131,7 +133,7 @@ class ExtractPlugin(PapersPlugin):
with fitz.Document(filename) as doc:
for page in doc:
for annot in page.annots():
content = self._retrieve_annotation_content(page, annot)
content = self._retrieve_annotation_content(page, annot, self.highlight_prefix, self.note_prefix)
if content:
annotations.append(f"[{(page.number or 0) + 1}] {content}")
return annotations