It is working.

I also strip the leading and trailing white space after that using strip().
Code:
def safe_format(fmt, kwargs_, error_value, book, **kwargs):
output = SafeFormat().safe_format(fmt, kwargs_, error_value, book, strip_results=False, **kwargs)
return output.strip()