Add configurable note and quote prefixes
This commit is contained in:
parent
f103cc51b5
commit
8f01b93de2
2 changed files with 12 additions and 1 deletions
|
@ -20,12 +20,21 @@ active = extract
|
||||||
|
|
||||||
[[extract]]
|
[[extract]]
|
||||||
on_import = False
|
on_import = False
|
||||||
|
quote_prefix = "> "
|
||||||
|
note_prefix = "Note: "
|
||||||
minimum_similarity = 0.75
|
minimum_similarity = 0.75
|
||||||
```
|
```
|
||||||
|
|
||||||
If `on_import` is `True` extraction is automatically run whenever a new document is added to the library,
|
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.
|
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
|
`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:
|
as one. Any annotation that has both and is *under* the minimum similarity will be added in the following form:
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,8 @@ class ExtractPlugin(PapersPlugin):
|
||||||
# and so on
|
# and so on
|
||||||
self.on_import = conf["plugins"].get("extract", {}).get("on_import", False)
|
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.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):
|
def update_parser(self, subparsers, conf):
|
||||||
"""Allow the usage of the pubs extract subcommand"""
|
"""Allow the usage of the pubs extract subcommand"""
|
||||||
|
@ -131,7 +133,7 @@ class ExtractPlugin(PapersPlugin):
|
||||||
with fitz.Document(filename) as doc:
|
with fitz.Document(filename) as doc:
|
||||||
for page in doc:
|
for page in doc:
|
||||||
for annot in page.annots():
|
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:
|
if content:
|
||||||
annotations.append(f"[{(page.number or 0) + 1}] {content}")
|
annotations.append(f"[{(page.number or 0) + 1}] {content}")
|
||||||
return annotations
|
return annotations
|
||||||
|
|
Loading…
Reference in a new issue