quoteIfNeeded package:hledger-lib
Double-quote this string if it contains whitespace, single quotes or
double-quotes, escaping the quotes as needed.
Single-quote this string if it contains whitespace or double-quotes.
Does not work for strings containing single quotes.