Refactor YAML exporter to be Pelican Markdown exporter

This commit is contained in:
MinchinWeb 2021-09-11 10:24:03 -06:00
parent 61f8406412
commit f43b643406
2 changed files with 11 additions and 7 deletions

View file

@ -7,19 +7,19 @@ from .fancy_exporter import FancyExporter
from .jrnl_importer import JRNLImporter from .jrnl_importer import JRNLImporter
from .json_exporter import JSONExporter from .json_exporter import JSONExporter
from .markdown_exporter import MarkdownExporter from .markdown_exporter import MarkdownExporter
from .pelican_markdown_exporter import PelicanMarkdownExporter
from .tag_exporter import TagExporter from .tag_exporter import TagExporter
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 TextExporter
from .xml_exporter import XMLExporter from .xml_exporter import XMLExporter
from .yaml_exporter import YAMLExporter
__exporters = [ __exporters = [
JSONExporter, JSONExporter,
MarkdownExporter, MarkdownExporter,
PelicanMarkdownExporter,
TagExporter, TagExporter,
TextExporter, TextExporter,
XMLExporter, XMLExporter,
YAMLExporter,
FancyExporter, FancyExporter,
] + template_exporters ] + template_exporters
__importers = [JRNLImporter] __importers = [JRNLImporter]

View file

@ -14,10 +14,14 @@ from jrnl.color import WARNING_COLOR
from .text_exporter import TextExporter from .text_exporter import TextExporter
class YAMLExporter(TextExporter): class PelicanMarkdownExporter(TextExporter):
"""This Exporter can convert entries and journals into Markdown formatted text with YAML front matter.""" """
This Exporter can convert entries and journals into Markdown formatted
text with YAML front matter, as may be used by Pelican (a static site
generator).
"""
names = ["yaml"] names = ["pelican-markdown"]
extension = "md" extension = "md"
@classmethod @classmethod
@ -25,8 +29,8 @@ class YAMLExporter(TextExporter):
"""Returns a markdown representation of a single entry, with YAML front matter.""" """Returns a markdown representation of a single entry, with YAML front matter."""
if to_multifile is False: if to_multifile is False:
print( print(
f"{ERROR_COLOR}ERROR{RESET_COLOR}: YAML export must be to individual files. Please \ f"{ERROR_COLOR}ERROR{RESET_COLOR}: Pelican Markdown export must \
specify a directory to export to.", be to individual files. Please specify a directory to export to.",
file=sys.stderr, file=sys.stderr,
) )
return return