From d44a6e8d18dcbe75625568c50d3d4da807ad3f42 Mon Sep 17 00:00:00 2001 From: Suhas Date: Tue, 2 Feb 2021 20:14:49 -0500 Subject: [PATCH] add pretty exporter --- jrnl/plugins/__init__.py | 3 ++- jrnl/plugins/text_exporter.py | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/jrnl/plugins/__init__.py b/jrnl/plugins/__init__.py index ad174f0b..f6b22c54 100644 --- a/jrnl/plugins/__init__.py +++ b/jrnl/plugins/__init__.py @@ -10,7 +10,7 @@ from .markdown_exporter import MarkdownExporter from .tag_exporter import TagExporter from .dates_exporter import DatesExporter from .template_exporter import __all__ as template_exporters -from .text_exporter import TextExporter +from .text_exporter import PrettyExporter, TextExporter from .xml_exporter import XMLExporter from .yaml_exporter import YAMLExporter @@ -20,6 +20,7 @@ __exporters = [ TagExporter, DatesExporter, TextExporter, + PrettyExporter, XMLExporter, YAMLExporter, FancyExporter, diff --git a/jrnl/plugins/text_exporter.py b/jrnl/plugins/text_exporter.py index 7714606c..2d316bb5 100644 --- a/jrnl/plugins/text_exporter.py +++ b/jrnl/plugins/text_exporter.py @@ -3,8 +3,10 @@ # Copyright (C) 2012-2021 jrnl contributors # License: https://www.gnu.org/licenses/gpl-3.0.html +from jrnl.Entry import Entry import os import re +from typing import Any, Union import unicodedata from jrnl.color import ERROR_COLOR @@ -77,3 +79,10 @@ class TextExporter: return cls.write_file(journal, output) else: return cls.export_journal(journal) + + +class PrettyExporter(TextExporter): + names=["pretty"] + @classmethod + def export_entry(cls, entry: Entry) -> Union[str, Any]: + return entry.pprint()