mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-12 01:18:31 +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
|
# encoding: utf-8
|
||||||
|
|
||||||
from __future__ import absolute_import, unicode_literals, print_function
|
from __future__ import absolute_import, unicode_literals, print_function
|
||||||
from .text_exporter import TextExporter
|
|
||||||
import sys
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
|
from .text_exporter import TextExporter
|
||||||
from ..util import WARNING_COLOR, ERROR_COLOR, RESET_COLOR
|
from ..util import WARNING_COLOR, ERROR_COLOR, RESET_COLOR
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,6 +28,17 @@ class PrjctExporter(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)
|
||||||
|
|
||||||
|
newbody = ''
|
||||||
|
for line in body.splitlines(True):
|
||||||
|
if multi_tag_regex.match(line):
|
||||||
|
"""Tag only lines"""
|
||||||
|
line = ''
|
||||||
|
newbody = newbody + line
|
||||||
|
|
||||||
# pass headings as is
|
# pass headings as is
|
||||||
|
|
||||||
if len(entry.tags) > 0:
|
if len(entry.tags) > 0:
|
||||||
|
@ -49,7 +63,7 @@ class PrjctExporter(TextExporter):
|
||||||
author="",
|
author="",
|
||||||
location=location_str,
|
location=location_str,
|
||||||
language="",
|
language="",
|
||||||
body=body,
|
body=newbody,
|
||||||
space="\n"
|
space="\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue