From d087c366c3a9811483c403a9381b3d423149dece Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 12 Jun 2024 11:05:13 +0200 Subject: [PATCH] chore: Refactor markdown format string handling --- papis_extract/__init__.py | 5 +++-- papis_extract/formatter.py | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/papis_extract/__init__.py b/papis_extract/__init__.py index 7944553..855d80f 100644 --- a/papis_extract/__init__.py +++ b/papis_extract/__init__.py @@ -88,10 +88,11 @@ def main( git: bool, force: bool, ) -> None: - """Extract annotations from any pdf document. + """Extract annotations from any documents. The extract plugin allows manual or automatic extraction of all annotations - contained in the pdf documents belonging to entries of the papis library. + contained in the documents belonging to entries of the papis library, + primarily targeting PDF documents currently. It can write those changes to stdout or directly create and update notes for papis documents. diff --git a/papis_extract/formatter.py b/papis_extract/formatter.py index 917e04c..76c977b 100644 --- a/papis_extract/formatter.py +++ b/papis_extract/formatter.py @@ -23,15 +23,13 @@ def format_markdown( heading = f"{document.get('title', '')} - {document.get('author', '')}" if headings == "atx": - output = f"# {heading}\n\n" + output += f"# {heading}\n\n" elif headings == "setext": title_decoration = ( f"{'=' * len(document.get('title', ''))} " f"{'-' * len(document.get('author', ''))}" ) - output = f"{title_decoration}\n{heading}\n{title_decoration}\n\n" - else: - output = "" + output += f"{title_decoration}\n{heading}\n{title_decoration}\n\n" for a in annotations: output += a.format(template)