diff --git a/jrnl/Entry.py b/jrnl/Entry.py index 66b32f6c..1e37accd 100755 --- a/jrnl/Entry.py +++ b/jrnl/Entry.py @@ -22,6 +22,12 @@ class Entry: pattern = r'(?u)\s([{tags}][-+*#/\w]+)'.format(tags=tagsymbols) return re.compile( pattern, re.UNICODE ) + @staticmethod + def title_regex(self): + pattern = r'^(([^|]|[^\s])[^\n]*)' + pattern = r'^20.*' + return re.compile( pattern, re.UNICODE|re.MULTILINE ) + def parse_tags(self): fulltext = " " + " ".join([self.title, self.body]).lower() tagsymbols = self.journal.config['tagsymbols'] diff --git a/jrnl/Journal.py b/jrnl/Journal.py index 92a6774f..e5cfd920 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -162,11 +162,14 @@ class Journal(object): for tag in self.search_tags: tagre = re.compile(re.escape(tag), re.IGNORECASE) pp = re.sub(tagre, - lambda match: util.colorize(match.group(0)), + lambda match: util.colorize_tags(match.group(0)), pp, re.UNICODE) else: pp = re.sub( Entry.Entry.tag_regex(self.config['tagsymbols']), - lambda match: util.colorize(match.group(0)), + lambda match: util.colorize_tags(match.group(0)), + pp) + pp = re.sub( Entry.Entry.title_regex(self.config['tagsymbols']), + lambda match: util.colorize_titles(match.group(0)), pp) return pp diff --git a/jrnl/util.py b/jrnl/util.py index e9df0fb1..996abeef 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -138,10 +138,14 @@ def get_text_from_editor(config, template=""): prompt('[Nothing saved to file]') return raw -def colorize(string): - """Returns the string wrapped in cyan ANSI escape""" +def colorize_tags(string): + """Returns the tag string wrapped in cyan ANSI escape""" return u"\033[36m{}\033[39m".format(string) +def colorize_titles(string): + """Returns the title string wrapped in cyan ANSI escape""" + return u"\033[1m\033[37m{}\033[0m".format(string) + def slugify(string): """Slugifies a string. Based on public domain code from https://github.com/zacharyvoase/slugify