mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 04:58:32 +02:00
add pretty exporter
This commit is contained in:
parent
1f8351a9f0
commit
d44a6e8d18
2 changed files with 11 additions and 1 deletions
|
@ -10,7 +10,7 @@ from .markdown_exporter import MarkdownExporter
|
||||||
from .tag_exporter import TagExporter
|
from .tag_exporter import TagExporter
|
||||||
from .dates_exporter import DatesExporter
|
from .dates_exporter import DatesExporter
|
||||||
from .template_exporter import __all__ as template_exporters
|
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 .xml_exporter import XMLExporter
|
||||||
from .yaml_exporter import YAMLExporter
|
from .yaml_exporter import YAMLExporter
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ __exporters = [
|
||||||
TagExporter,
|
TagExporter,
|
||||||
DatesExporter,
|
DatesExporter,
|
||||||
TextExporter,
|
TextExporter,
|
||||||
|
PrettyExporter,
|
||||||
XMLExporter,
|
XMLExporter,
|
||||||
YAMLExporter,
|
YAMLExporter,
|
||||||
FancyExporter,
|
FancyExporter,
|
||||||
|
|
|
@ -3,8 +3,10 @@
|
||||||
# Copyright (C) 2012-2021 jrnl contributors
|
# Copyright (C) 2012-2021 jrnl contributors
|
||||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
|
from jrnl.Entry import Entry
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
from typing import Any, Union
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
|
||||||
from jrnl.color import ERROR_COLOR
|
from jrnl.color import ERROR_COLOR
|
||||||
|
@ -77,3 +79,10 @@ class TextExporter:
|
||||||
return cls.write_file(journal, output)
|
return cls.write_file(journal, output)
|
||||||
else:
|
else:
|
||||||
return cls.export_journal(journal)
|
return cls.export_journal(journal)
|
||||||
|
|
||||||
|
|
||||||
|
class PrettyExporter(TextExporter):
|
||||||
|
names=["pretty"]
|
||||||
|
@classmethod
|
||||||
|
def export_entry(cls, entry: Entry) -> Union[str, Any]:
|
||||||
|
return entry.pprint()
|
||||||
|
|
Loading…
Add table
Reference in a new issue