[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[4663] branches/1.3/LedgerSMB/Template/LaTeX.pm



Revision: 4663
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4663&view=rev
Author:   ehuelsmann
Date:     2012-04-23 10:12:48 +0000 (Mon, 23 Apr 2012)
Log Message:
-----------
Encode a single backslash not as a double backslash, but as a LaTeX command.

Modified Paths:
--------------
    branches/1.3/LedgerSMB/Template/LaTeX.pm

Modified: branches/1.3/LedgerSMB/Template/LaTeX.pm
===================================================================
--- branches/1.3/LedgerSMB/Template/LaTeX.pm	2012-04-23 10:01:16 UTC (rev 4662)
+++ branches/1.3/LedgerSMB/Template/LaTeX.pm	2012-04-23 10:12:48 UTC (rev 4663)
@@ -99,13 +99,27 @@
 	return $vars;
 }
 
+my %escapes = (
+   '&' => '\\&',
+   '$' => '\\$',
+   '\\' => '{\\textbackslash}',
+   '_' => '\\_',
+   '<' => '\\<',
+   '>' => '\\>',
+   '~' => '\\~',
+   '^' => '\\^',
+   '#' => '\\#',
+   '%' => '\\%',
+   '{' => '\\{',
+   '}' => '\\}',
+  );
 
 # Breaking this off to be used separately.
 sub escape {
     my ($vars) = shift @_;
 
     if (defined $vars){
-            $vars =~ s/([&\$\\_<>~^#\%\{\}])/\\$1/g;
+            $vars =~ s/([&\$\\_<>~^#\%\{\}])/$escapes{$1}/g;
             $vars =~ s/â/--/g;
             $vars =~ s/[ââ]/---/g;
             $vars =~ s/"(.*)"/``$1''/gs;

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.