mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
[YAML export] remove lines that simply list tags
This commit is contained in:
parent
327fde5c0f
commit
db4a5a4665
1 changed files with 8 additions and 1 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Reference in a new issue