From db4a5a46652d283d487e88785ff19105edac3c43 Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Sun, 3 May 2015 21:34:11 -0600 Subject: [PATCH] [YAML export] remove lines that simply list tags --- jrnl/plugins/yaml_exporter.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/jrnl/plugins/yaml_exporter.py b/jrnl/plugins/yaml_exporter.py index 697001ba..7a5bc5a0 100644 --- a/jrnl/plugins/yaml_exporter.py +++ b/jrnl/plugins/yaml_exporter.py @@ -8,7 +8,7 @@ import sys import yaml -class MarkdownExporter(TextExporter): +class YAMLExporter(TextExporter): """This Exporter can convert entries and journals into Markdown with YAML front matter.""" names = ["yaml"] extension = "md" @@ -24,6 +24,10 @@ class MarkdownExporter(TextExporter): body_wrapper = "\n" if entry.body else "" body = body_wrapper + entry.body + tagsymbols = entry.journal.config['tagsymbols'] + # see also Entry.Entry.rag_regex + multi_tag_regex = re.compile(r'(?u)^\s*([{tags}][-+*#/\w]+\s*)+$'.format(tags=tagsymbols), re.UNICODE) + '''Increase heading levels in body text''' newbody = '' heading = '#' @@ -44,6 +48,9 @@ class MarkdownExporter(TextExporter): """Setext style H2""" newbody = newbody + heading + "## " + previous_line line = '' + elif multi_tag_regex.match(line): + """Tag only lines""" + line = '' else: newbody = newbody + previous_line previous_line = line