From f034c250b63ca196d5887a8911bcebcc16c23220 Mon Sep 17 00:00:00 2001 From: tetragon Date: Thu, 27 Mar 2008 03:05:25 +0000 Subject: More progress on handling format_string and double-escaping in TeX git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/branches/1.2@2118 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/Form.pm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm index 0725005f..a7d8c6e9 100755 --- a/LedgerSMB/Form.pm +++ b/LedgerSMB/Form.pm @@ -1258,6 +1258,7 @@ sub format_line { sub cleanup { + return; my $self = shift; chdir("$self->{tmpdir}"); @@ -1312,10 +1313,11 @@ sub format_string { html => [ '<', '>', '\n', '\r', '&' ], txt => [ '\n', '\r' ], tex => [ - quotemeta('\\'), '&', '\n', '\r', - quotemeta('$'), '%', '#', +# quotemeta('\\'), '&', '\n', '\r', + '&', '\n', '\r', + quotemeta('$'), '%', '(?', '£' + '>', '£', ] }, html => { @@ -1334,17 +1336,23 @@ sub format_string { quotemeta('^') => '\^\\', '{' => '\{', '}' => '\}', + '(? '\_', # SC: Double escaping is annoying '<' => '$<$', '>' => '$>$', '\n' => '\newline ', '\r' => '\newline ', '£' => '\pounds ', - quotemeta('\\') => '/' +# quotemeta('\\') => '/' } ); my $key; + if ($format eq 'tex') { + FIELD: for (@fields) { + $self->{$_} =~ s{\\(?!pounds\b|newline\b|\$|%|#|&|\{|\}|\^\\|_)}{/}g; + } + } CHAR: foreach $key ( @{ $replace{order}{$format} } ) { FIELD: for (@fields) { $self->{$_} =~ s/$key/$replace{$format}{$key}/g; -- cgit v1.2.3