From af3e054b33ce5bd4493702d764629ad2b8b9c472 Mon Sep 17 00:00:00 2001 From: Brian Ecker Date: Fri, 1 Dec 2017 23:31:47 +0100 Subject: [PATCH] Pretty print titles as bold. --- jrnl/Entry.py | 4 ++-- jrnl/util.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/jrnl/Entry.py b/jrnl/Entry.py index 1306cef5..f32f0985 100755 --- a/jrnl/Entry.py +++ b/jrnl/Entry.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import re import textwrap from datetime import datetime -from .util import split_title +from .util import split_title, bold class Entry: @@ -100,7 +100,7 @@ class Entry: return title else: return "{title}{sep}{body}\n".format( - title=title, + title=bold(title), sep="\n" if has_body else "", body=body if has_body else "", ) diff --git a/jrnl/util.py b/jrnl/util.py index f6a7735f..67142df2 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -178,6 +178,11 @@ def colorize(string): return u"\033[36m{}\033[39m".format(string) +def bold(string): + """Returns the string wrapped in bold ANSI escape""" + return u"\033[1m{}\033[0m".format(string) + + def slugify(string): """Slugifies a string. Based on public domain code from https://github.com/zacharyvoase/slugify