Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision dc3cd296

Von Moritz Bunkus vor fast 17 Jahren hinzugefügt

  • ID dc3cd296e62eb09a16fa694d9b3a7158e4cf63bf
  • Vorgänger 0aea1ede
  • Nachfolger 0c75bd00

Das Quoten/Unquoten von speziellen Zeichen in zentrale Hilfsfunktionen in Locale verlagert.

Unterschiede anzeigen:

SL/Template.pm
99 99
  my ($self, $variable) = @_;
100 100
  my $form = $self->{"form"};
101 101

  
102
  my %replace =
103
    ('order' => [quotemeta("\\"),
104
                 '<pagebreak>',
105
                 '&', quotemeta("\n"),
106
                 '"', '\$', '%', '_', '#', quotemeta('^'),
107
                 '{', '}',  '<', '>', '?', "\r", '?', '\xe1',
108
                 '?', '?',
109

  
110
                 ],
111
     quotemeta("\\") => '\\textbackslash ',
112
     '<pagebreak>'   => '',
113
     '"'             => "''",
114
     '&'             => '\&',
115
     '\$'            => '\$',
116
     '%'             => '\%',
117
     '_'             => '\_',
118
     '#'             => '\#',
119
     '{'             => '\{',
120
     '}'             => '\}',
121
     '<'             => '$<$',
122
     '>'             => '$>$',
123
     '?'             => '\pounds ',
124
     "\r"            => "",
125
     '?'             => '$\pm$',
126
     '\xe1'          => '$\bullet$',
127
     quotemeta('^')  => '\^\\',
128
     quotemeta("\n") => '\newline ',
129
     '?'             => '$^2$',
130
     '?'             => '$^3$',
131
     );
132

  
133
  map({ $variable =~ s/$_/$replace{$_}/g; } @{ $replace{"order"} });
102
  $variable = $main::locale->quote_special_chars('Template/LaTeX', $variable);
134 103

  
135 104
  # Allow some HTML markup to be converted into the output format's
136 105
  # corresponding markup code, e.g. bold or italic.
......
594 563
  my ($self, $variable) = @_;
595 564
  my $form = $self->{"form"};
596 565

  
597
  my %replace =
598
    ('order' => ['<', '>', quotemeta("\n")],
599
     '<'             => '&lt;',
600
     '>'             => '&gt;',
601
     quotemeta("\n") => '<br>',
602
     );
603

  
604
  map({ $variable =~ s/$_/$replace{$_}/g; } @{ $replace{"order"} });
566
  $variable = $main::locale->quote_special_chars('Template/HTML', $variable);
605 567

  
606 568
  # Allow some HTML markup to be converted into the output format's
607 569
  # corresponding markup code, e.g. bold or italic.
......
1342 1304
  my $form = $self->{"form"};
1343 1305
  my $iconv = $self->{"iconv"};
1344 1306

  
1345
  my %replace =
1346
    ('order' => ['&', '<', '>', '"', "'",
1347
                 '\x80',        # Euro
1348
                 quotemeta("\n"), quotemeta("\r")],
1349
     '<'             => '&lt;',
1350
     '>'             => '&gt;',
1351
     '"'             => '&quot;',
1352
     "'"             => '&apos;',
1353
     '&'             => '&amp;',
1354
     '\x80'          => chr(0xa4), # Euro
1355
     quotemeta("\n") => '<text:line-break/>',
1356
     quotemeta("\r") => '',
1357
     );
1358

  
1359
  map({ $variable =~ s/$_/$replace{$_}/g; } @{ $replace{"order"} });
1307
  $variable = $main::locale->quote_special_chars('Template/OpenDocument', $variable);
1360 1308

  
1361 1309
  # Allow some HTML markup to be converted into the output format's
1362 1310
  # corresponding markup code, e.g. bold or italic.
......
1409 1357
  my ($self, $variable) = @_;
1410 1358
  my $form = $self->{"form"};
1411 1359

  
1412
  my %replace =
1413
    ('order' => ['<', '>', quotemeta("\n")],
1414
     '<'             => '&lt;',
1415
     '>'             => '&gt;',
1416
     quotemeta("\n") => '<br>',
1417
     );
1418

  
1419
  map({ $variable =~ s/$_/$replace{$_}/g; } @{ $replace{"order"} });
1360
  $variable = $main::locale->quote_special_chars('Template/XML', $variable);
1420 1361

  
1421 1362
  # Allow no markup to be converted into the output format
1422 1363
  my @markup_replace = ('b', 'i', 's', 'u', 'sub', 'sup');

Auch abrufbar als: Unified diff