Pretty print titles as bold.

This commit is contained in:
Brian Ecker 2017-12-01 23:31:47 +01:00
parent 8615679beb
commit af3e054b33
2 changed files with 7 additions and 2 deletions

View file

@ -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 "",
)

View file

@ -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