From bb6e1e3ce2cdc189aecf7d0a2790124dbd6c5c48 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Mon, 3 Feb 2020 10:10:46 -0800 Subject: [PATCH] ;lib: export textQuoteIfNeeded [ci skip] --- hledger-lib/Hledger/Utils/Text.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hledger-lib/Hledger/Utils/Text.hs b/hledger-lib/Hledger/Utils/Text.hs index 879b67033..cabe127a1 100644 --- a/hledger-lib/Hledger/Utils/Text.hs +++ b/hledger-lib/Hledger/Utils/Text.hs @@ -14,7 +14,7 @@ module Hledger.Utils.Text textUnbracket, -- -- quoting quoteIfSpaced, - -- quoteIfNeeded, + textQuoteIfNeeded, -- singleQuoteIfNeeded, -- -- quotechars, -- -- whitespacechars, @@ -127,7 +127,7 @@ textElideRight width t = quoteIfSpaced :: T.Text -> T.Text quoteIfSpaced s | isSingleQuoted s || isDoubleQuoted s = s | not $ any (`elem` (T.unpack s)) whitespacechars = s - | otherwise = quoteIfNeeded s + | otherwise = textQuoteIfNeeded s -- -- | Wrap a string in double quotes, and \-prefix any embedded single -- -- quotes, if it contains whitespace and is not already single- or @@ -139,9 +139,9 @@ quoteIfSpaced s | isSingleQuoted s || isDoubleQuoted s = s -- -- | Double-quote this string if it contains whitespace, single quotes -- -- or double-quotes, escaping the quotes as needed. -quoteIfNeeded :: T.Text -> T.Text -quoteIfNeeded s | any (`elem` T.unpack s) (quotechars++whitespacechars) = "\"" <> escapeDoubleQuotes s <> "\"" - | otherwise = s +textQuoteIfNeeded :: T.Text -> T.Text +textQuoteIfNeeded s | any (`elem` T.unpack s) (quotechars++whitespacechars) = "\"" <> escapeDoubleQuotes s <> "\"" + | otherwise = s -- -- | Single-quote this string if it contains whitespace or double-quotes. -- -- No good for strings containing single quotes.