Properly display entries during a tag search. (#902)

This commit is contained in:
notbalanced 2020-04-04 14:32:04 -04:00
parent f57dcf5cab
commit aece970751
2 changed files with 11 additions and 1 deletions

View file

@ -97,4 +97,14 @@ Feature: Tagging
| Text before @tag. And After. | Text before @tag. And After.
| @hi. Hello | @hi. Hello
| hi Hello | hi Hello
"""
Scenario: Searching a journal for tags should display entries with that tag.
Given we use the config "tags.yaml"
When we run "jrnl @dan"
Then the output should be
"""
2013-06-10 15:40 I met with @dan.
| As alway's he shared his latest @idea on how to rule the world with me.
| inst
""" """

View file

@ -228,7 +228,7 @@ def highlight_tags_with_background_color(entry, text, color, is_title=False):
text_fragments = [] text_fragments = []
for tag in entry.journal.search_tags: for tag in entry.journal.search_tags:
text_fragments.extend( text_fragments.extend(
re.split(re.compile(re.escape(tag), re.IGNORECASE), text) re.split(re.compile(f"({re.escape(tag)})", re.IGNORECASE), text)
) )
else: else:
text_fragments = re.split(entry.tag_regex(config["tagsymbols"]), text) text_fragments = re.split(entry.tag_regex(config["tagsymbols"]), text)