From dd81c7dbed2f9c3182003c594658864a62ed52c0 Mon Sep 17 00:00:00 2001 From: Aaron Lichtman Date: Fri, 8 Nov 2019 01:25:00 +0100 Subject: [PATCH] Closer to working tag colorization but not perfect --- jrnl/util.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jrnl/util.py b/jrnl/util.py index a4ba89e1..915f50cc 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -249,10 +249,13 @@ def highlight_tags_with_background_color(entry, text, color, bold=False): final_text = "" previous_piece = "" for colorized_piece, piece in colorized_text_generator(text_fragments): - if piece in punctuation and previous_piece[0] not in config['tagsymbols']: - final_text = final_text.strip() + colorized_piece + # If it's punctuation and the previous word was a tag, add it directly after the tag. + # TODO: This logic seems flawed... + if piece in punctuation and previous_piece[0] in config['tagsymbols']: + final_text = final_text.lstrip() + colorized_piece else: - final_text += colorized_piece + " " + # Otherwise just append it. + final_text += " " + colorized_piece previous_piece = piece