From aece97075184a098291f321474a1563402c2efec Mon Sep 17 00:00:00 2001 From: notbalanced Date: Sat, 4 Apr 2020 14:32:04 -0400 Subject: [PATCH] Properly display entries during a tag search. (#902) --- features/tagging.feature | 10 ++++++++++ jrnl/util.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/features/tagging.feature b/features/tagging.feature index 8b4cefb7..b20c2b3d 100644 --- a/features/tagging.feature +++ b/features/tagging.feature @@ -97,4 +97,14 @@ Feature: Tagging | Text before @tag. And After. | @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 """ \ No newline at end of file diff --git a/jrnl/util.py b/jrnl/util.py index 1acf89e6..154b0b28 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -228,7 +228,7 @@ def highlight_tags_with_background_color(entry, text, color, is_title=False): text_fragments = [] for tag in entry.journal.search_tags: 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: text_fragments = re.split(entry.tag_regex(config["tagsymbols"]), text)