X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fhomebank2ledger;a=blobdiff_plain;f=lib%2FApp%2FHomeBank2Ledger%2FFormatter%2FLedger.pm;fp=lib%2FApp%2FHomeBank2Ledger%2FFormatter%2FLedger.pm;h=71d9020249983e6943620bb52f379daa32ed04ba;hp=677facb02e72a5924617ca4e726424921d9497f7;hb=9a270ef9470db7ca110c2ad60fcd13f8674fdf63;hpb=2cb8cd6b61921ef8f051f9066411deb4c829b68d diff --git a/lib/App/HomeBank2Ledger/Formatter/Ledger.pm b/lib/App/HomeBank2Ledger/Formatter/Ledger.pm index 677facb..71d9020 100644 --- a/lib/App/HomeBank2Ledger/Formatter/Ledger.pm +++ b/lib/App/HomeBank2Ledger/Formatter/Ledger.pm @@ -269,6 +269,13 @@ sub _format_string { return $str; } +sub _quote_string { + my $self = shift; + my $str = shift; + $str =~ s/"/\\"/g; + return "\"$str\""; +} + sub _format_amount { my $self = shift; my $amount = shift; @@ -279,7 +286,10 @@ sub _format_amount { my $num = join($commodity->{dchar}, commify($whole, $commodity->{gchar}), $fraction); - $num = $commodity->{syprf} ? "$commodity->{symbol} $num" : "$num $commodity->{symbol}"; + my $symbol = $commodity->{symbol}; + $symbol = $self->_quote_string($symbol) if $symbol =~ /[0-9\s]/; + + $num = $commodity->{syprf} ? "$symbol $num" : "$num $symbol"; return $num; }