From a2ebbcb7fef17da7956ddc5d90b3d7962b51793e Mon Sep 17 00:00:00 2001 From: Ben Fiedler Date: Mon, 18 Jul 2022 08:48:47 +0200 Subject: [PATCH] imp: Add ' as possible digit separator It is used for Swiss Francs: CHF 1'000. --- hledger-lib/Hledger/Read/Common.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hledger-lib/Hledger/Read/Common.hs b/hledger-lib/Hledger/Read/Common.hs index 02c2b1d93906..98faa80aaf24 100644 --- a/hledger-lib/Hledger/Read/Common.hs +++ b/hledger-lib/Hledger/Read/Common.hs @@ -995,6 +995,8 @@ disambiguateNumber msuggestedStyle (AmbiguousNumber grp1 sep grp2) = -- Left (AmbiguousNumber "1" ',' "000") -- >>> parseTest rawnumberp "1 000" -- Right (WithSeparators ' ' ["1","000"] Nothing) +-- >>> parseTest rawnumberp "1'000" +-- Right (WithSeparators '\'' ["1","000"] Nothing) -- rawnumberp :: TextParser m (Either AmbiguousNumber RawNumber) rawnumberp = label "number" $ do @@ -1060,7 +1062,7 @@ rawnumberp = label "number" $ do pure $ NoSeparators grp1 (Just (decPt, mempty)) isDigitSeparatorChar :: Char -> Bool -isDigitSeparatorChar c = isDecimalMark c || c == ' ' +isDigitSeparatorChar c = isDecimalMark c || c == ' ' || c == '\'' -- | Some kinds of number literal we might parse. data RawNumber