From 89eba3e2745c4ff507e3e78d8480ffb249157133 Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Mon, 15 Feb 2016 23:32:41 -0700 Subject: [PATCH] [Prjct Exporter] remove tag only lines --- jrnl/plugins/prjct_exporter.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/jrnl/plugins/prjct_exporter.py b/jrnl/plugins/prjct_exporter.py index d0098e4e..f09d3370 100644 --- a/jrnl/plugins/prjct_exporter.py +++ b/jrnl/plugins/prjct_exporter.py @@ -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" )