Closer to working tag colorization but not perfect

This commit is contained in:
Aaron Lichtman 2019-11-08 01:25:00 +01:00
parent e9bfe4dcac
commit dd81c7dbed
No known key found for this signature in database
GPG key ID: 22368077DE9F9903

View file

@ -249,10 +249,13 @@ def highlight_tags_with_background_color(entry, text, color, bold=False):
final_text = "" final_text = ""
previous_piece = "" previous_piece = ""
for colorized_piece, piece in colorized_text_generator(text_fragments): for colorized_piece, piece in colorized_text_generator(text_fragments):
if piece in punctuation and previous_piece[0] not in config['tagsymbols']: # If it's punctuation and the previous word was a tag, add it directly after the tag.
final_text = final_text.strip() + colorized_piece # TODO: This logic seems flawed...
if piece in punctuation and previous_piece[0] in config['tagsymbols']:
final_text = final_text.lstrip() + colorized_piece
else: else:
final_text += colorized_piece + " " # Otherwise just append it.
final_text += " " + colorized_piece
previous_piece = piece previous_piece = piece