[YAML export] remove lines that simply list tags

This commit is contained in:
MinchinWeb 2015-05-03 21:34:11 -06:00
parent 327fde5c0f
commit db4a5a4665

View file

@ -8,7 +8,7 @@ import sys
import yaml import yaml
class MarkdownExporter(TextExporter): class YAMLExporter(TextExporter):
"""This Exporter can convert entries and journals into Markdown with YAML front matter.""" """This Exporter can convert entries and journals into Markdown with YAML front matter."""
names = ["yaml"] names = ["yaml"]
extension = "md" extension = "md"
@ -24,6 +24,10 @@ class MarkdownExporter(TextExporter):
body_wrapper = "\n" if entry.body else "" body_wrapper = "\n" if entry.body else ""
body = body_wrapper + entry.body 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''' '''Increase heading levels in body text'''
newbody = '' newbody = ''
heading = '#' heading = '#'
@ -44,6 +48,9 @@ class MarkdownExporter(TextExporter):
"""Setext style H2""" """Setext style H2"""
newbody = newbody + heading + "## " + previous_line newbody = newbody + heading + "## " + previous_line
line = '' line = ''
elif multi_tag_regex.match(line):
"""Tag only lines"""
line = ''
else: else:
newbody = newbody + previous_line newbody = newbody + previous_line
previous_line = line previous_line = line