Revision e7361d77
Von Moritz Bunkus vor fast 17 Jahren hinzugefügt
SL/Template.pm | ||
---|---|---|
415 | 415 |
} |
416 | 416 |
} |
417 | 417 |
|
418 |
sub _force_mandatory_packages { |
|
419 |
my $self = shift; |
|
420 |
my $lines = shift; |
|
421 |
|
|
422 |
my (%used_packages, $document_start_line); |
|
423 |
|
|
424 |
foreach my $i (0 .. scalar @{ $lines } - 1) { |
|
425 |
if ($lines->[$i] =~ m/\\usepackage[^{]*{(.*?)}/) { |
|
426 |
$used_packages{$1} = 1; |
|
427 |
|
|
428 |
} elsif ($lines->[$i] =~ m/\\begin{document}/) { |
|
429 |
$document_start_line = $i; |
|
430 |
last; |
|
431 |
|
|
432 |
} |
|
433 |
} |
|
434 |
|
|
435 |
$document_start_line = scalar @{ $lines } - 1 if (!defined $document_start_line); |
|
436 |
|
|
437 |
if (!$used_packages{textcomp}) { |
|
438 |
splice @{ $lines }, $document_start_line, 0, "\\usepackage{textcomp}\n"; |
|
439 |
$document_start_line++; |
|
440 |
} |
|
441 |
} |
|
442 |
|
|
418 | 443 |
sub parse { |
419 | 444 |
my $self = $_[0]; |
420 | 445 |
local *OUT = $_[1]; |
... | ... | |
428 | 453 |
close(IN); |
429 | 454 |
|
430 | 455 |
$self->_parse_config_lines(\@lines); |
456 |
$self->_force_mandatory_packages(\@lines); |
|
431 | 457 |
|
432 | 458 |
my $contents = join("", @lines); |
433 | 459 |
|
Auch abrufbar als: Unified diff
Forcieren, dass bei LaTeX-Vorlagen das Paket "textcomp" eingebunden wird, das für das Euro-Zeichen benötigt wird.