[Prjct Exporter] remove tag only lines

This commit is contained in:
MinchinWeb 2016-02-15 23:32:41 -07:00
parent 1c244da79b
commit 89eba3e274

View file

@ -2,8 +2,11 @@
# encoding: utf-8
from __future__ import absolute_import, unicode_literals, print_function
from .text_exporter import TextExporter
import sys
import re
from .text_exporter import TextExporter
from ..util import WARNING_COLOR, ERROR_COLOR, RESET_COLOR
@ -25,6 +28,17 @@ class PrjctExporter(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)
newbody = ''
for line in body.splitlines(True):
if multi_tag_regex.match(line):
"""Tag only lines"""
line = ''
newbody = newbody + line
# pass headings as is
if len(entry.tags) > 0:
@ -49,7 +63,7 @@ class PrjctExporter(TextExporter):
author="",
location=location_str,
language="",
body=body,
body=newbody,
space="\n"
)