journal: really don't parse + before an amount as part of the commodity (fixes #181 harder)
This commit is contained in:
parent
8341b4a8d3
commit
70ad5b26ff
@ -17,8 +17,8 @@ import Hledger.Data.Types
|
|||||||
import Hledger.Utils
|
import Hledger.Utils
|
||||||
|
|
||||||
|
|
||||||
-- characters than can't be in a non-quoted commodity symbol
|
-- characters that may not be used in a non-quoted commodity symbol
|
||||||
nonsimplecommoditychars = "0123456789-.@;\n \"{}=" :: String
|
nonsimplecommoditychars = "0123456789-+.@;\n \"{}=" :: String
|
||||||
|
|
||||||
quoteCommoditySymbolIfNeeded s | any (`elem` nonsimplecommoditychars) s = "\"" ++ s ++ "\""
|
quoteCommoditySymbolIfNeeded s | any (`elem` nonsimplecommoditychars) s = "\"" ++ s ++ "\""
|
||||||
| otherwise = s
|
| otherwise = s
|
||||||
|
|||||||
@ -658,12 +658,12 @@ signp = do
|
|||||||
leftsymbolamount :: GenParser Char JournalContext Amount
|
leftsymbolamount :: GenParser Char JournalContext Amount
|
||||||
leftsymbolamount = do
|
leftsymbolamount = do
|
||||||
sign <- signp
|
sign <- signp
|
||||||
let applysign = if sign=="-" then negate else id
|
|
||||||
c <- commoditysymbol
|
c <- commoditysymbol
|
||||||
sp <- many spacenonewline
|
sp <- many spacenonewline
|
||||||
(q,prec,dec,sep,seppos) <- numberp
|
(q,prec,dec,sep,seppos) <- numberp
|
||||||
let s = amountstyle{ascommodityside=L, ascommodityspaced=not $ null sp, asdecimalpoint=dec, asprecision=prec, asseparator=sep, asseparatorpositions=seppos}
|
let s = amountstyle{ascommodityside=L, ascommodityspaced=not $ null sp, asdecimalpoint=dec, asprecision=prec, asseparator=sep, asseparatorpositions=seppos}
|
||||||
p <- priceamount
|
p <- priceamount
|
||||||
|
let applysign = if sign=="-" then negate else id
|
||||||
return $ applysign $ Amount c q p s
|
return $ applysign $ Amount c q p s
|
||||||
<?> "left-symbol amount"
|
<?> "left-symbol amount"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user