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

SF.net SVN: ledger-smb:[6489] trunk



Revision: 6489
          http://sourceforge.net/p/ledger-smb/code/6489
Author:   einhverfr
Date:     2014-01-17 04:30:27 +0000 (Fri, 17 Jan 2014)
Log Message:
-----------
Moving LaTeX encoding to TeX::Encode which should solve a lot of headaches regarding UTF-8 strings

Modified Paths:
--------------
    trunk/LedgerSMB/Template/LaTeX.pm
    trunk/Makefile.PL

Modified: trunk/LedgerSMB/Template/LaTeX.pm
===================================================================
--- trunk/LedgerSMB/Template/LaTeX.pm	2014-01-17 04:12:57 UTC (rev 6488)
+++ trunk/LedgerSMB/Template/LaTeX.pm	2014-01-17 04:30:27 UTC (rev 6489)
@@ -59,6 +59,7 @@
 use LedgerSMB::Template::TTI18N;
 use Log::Log4perl;
 use LedgerSMB::Template::DB;
+use TeX::Encode;
 
 #my $binmode = ':utf8';
 my $binmode = ':raw';
@@ -104,52 +105,23 @@
 	return $vars;
 }
 
-my %escapes = (
-   '&' => '\\&',
-   '$' => '\\$',
-   '\\' => '{\\textbackslash}',
-   '_' => '\\_',
-   '<' => '\\<',
-   '>' => '\\>',
-   '~' => '\\~',
-   '^' => '\\^',
-   '#' => '\\#',
-   '%' => '\\%',
-   '{' => '\\{',
-   '}' => '\\}',
-   '–' => '---',
-  );
-
 # Breaking this off to be used separately.
 sub escape {
     my ($vars) = shift @_;
 
-    if (defined $vars){
-            $vars =~ s/([&\$\\_<>~^#\%\{\}])/$escapes{$1}/g;
-            $vars =~ s/[—―]/---/g;
-            $vars =~ s/\xa0/ /g;
-            $vars =~ s/\x91/'/g;
-            $vars =~ s/\x92/'/g;
-            $vars =~ s/\x93/"/g;
-            $vars =~ s/\x94/"/g;
-            $vars =~ s/\x97/-/g;
-            $vars =~ s/\xab/"/g;
-            $vars =~ s/\xa9//g;
-            $vars =~ s/\xae//g;
-            $vars =~ s/\x{2018}/'/g;
-            $vars =~ s/\x{2019}/'/g;
-            $vars =~ s/\x{201C}/"/g;
-            $vars =~ s/\x{201D}/"/g;
-            $vars =~ s/\x{2022}//g;
-            $vars =~ s/\x{2013}/-/g;
-            $vars =~ s/\x{2014}/-/g;
-            $vars =~ s/\x{2122}//g; 
-            $vars =~ s/–/--/g;
-            $vars =~ s/"(.*)"/``$1''/gs;
+    $vars =~ s/-/......hyphen....../g;
+    $vars =~ s/\+/......plus....../g; 
+
+    # For some reason this doesnt handle hyphens or +'s, so handling those
+    # above and below -CT
+    $vars = TeX::Encode::encode('latex', $vars);
+    if (defined $vars){ # Newline handling
             $vars =~ s/\n/\\\\/gm;
             $vars =~ s/(\\)*$//g;
             $vars =~ s/(\\\\){2,}/\n\n/g;
     }
+    $vars =~ s/\.\.\.\.\.\.hyphen\.\.\.\.\.\./-/g;
+    $vars =~ s/\.\.\.\.\.\.plus\.\.\.\.\.\./+/g; 
     return $vars;
 }
 

Modified: trunk/Makefile.PL
===================================================================
--- trunk/Makefile.PL	2014-01-17 04:12:57 UTC (rev 6488)
+++ trunk/Makefile.PL	2014-01-17 04:30:27 UTC (rev 6489)
@@ -76,7 +76,8 @@
 # Rendering options
 feature 'PDF and Postscript output',
     -default => 0,
-    'Template::Plugin::Latex' => 0;
+    'Template::Plugin::Latex' => 0,
+    'TeX::Encode' => 0;
 
 feature 'OpenOffice.org output',
     -default => 0,

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


------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits