mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-11 09:08:32 +02:00
[Prjct Exporter] remove tag only lines
This commit is contained in:
parent
1c244da79b
commit
89eba3e274
1 changed files with 16 additions and 2 deletions
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue