From 0d19f1790f886b86c5e0255d52e2f64ff2ec8caa Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Wed, 30 May 2012 17:58:26 +0200 Subject: [PATCH] Fixes highlighting --- jrnl/Journal.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jrnl/Journal.py b/jrnl/Journal.py index cf692109..b8c18651 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -137,9 +137,12 @@ class Journal: sep = "-"*60+"\n" pp = sep.join([str(e) for e in self.entries]) if self.config['highlight']: # highlight tags - if hasattr(self, 'search_tags'): + if self.search_tags: for tag in self.search_tags: - pp = pp.replace(tag, self._colorize(tag)) + tagre = re.compile(re.escape(tag), re.IGNORECASE) + pp = re.sub(tagre, + lambda match: self._colorize(match.group(0), 'cyan'), + pp) else: pp = re.sub(r"([%s]\w+)" % self.config['tagsymbols'], lambda match: self._colorize(match.group(0), 'cyan'),