}
# Prototypes
-sub initLyxStack($$);
+sub initLyxStack($$$);
sub diestack($);
sub closeLyxStack();
sub setMatching($);
my @stack = (); # list of HASH-Arrays
my $rFont = {};
my $useNonTexFont = "true";
+my $inputEncoding = undef;
# The elements are:
# type (layout, inset, header, preamble, ...)
# but first set the modified value into $result->[$fileidx]
# numerical value will be replaced with appropriate matching group value
-sub initLyxStack($$)
+sub initLyxStack($$$)
{
$rFont = $_[0];
if ($_[1] eq "systemF") {
}
else {
$useNonTexFont = "false";
+ $inputEncoding = $_[2];
}
$stack[0] = { type => "Starting"};
}
"result" => ["\\master ", ""]);
if (keys %{$rFont}) {
for my $ff ( keys %{$rFont}) {
- my $elem = newMatch("search" => '^\\\\font_' . $ff . '\s+',
+ # fontentry of type '\font_roman default'
+ my $elem = newMatch("search" => '^\\\\font_' . $ff . '\s+[^"]*\s*$',
"filetype" => "replace_only",
"result" => ["\\font_$ff ", $rFont->{$ff}]);
- push(@rElems, $elem);
+ # fontentry of type '\font_roman "default"'
+ my $elem1 = newMatch("search" => '^\\\\font_' . $ff . '\s+"[^"]*"\s*$',
+ "filetype" => "replace_only",
+ "result" => ["\\font_$ff \"", $rFont->{$ff}, '"']);
+ # fontentry of type '\font_roman "default" "default"'
+ my $elem2 = newMatch("search" => '^\\\\font_' . $ff . '\s+"(.*)"\s+"default"\s*$',
+ "filetype" => "replace_only",
+ "result" => ["\\font_$ff ", '"', "1", '" "', $rFont->{$ff}, '"']);
+ push(@rElems, $elem, $elem1, $elem2);
}
}
my $elemntf = newMatch("search" => '^\\\\use_non_tex_fonts\s+(false|true)',
"filetype" => "replace_only",
"result" => ["\\use_non_tex_fonts $useNonTexFont"]);
push(@rElems, $elemntf);
+ if (defined($inputEncoding)) {
+ my $inputenc = newMatch("search" => '^\\\\inputencoding\s+(' . $inputEncoding->{search} . ')',
+ "filetype" => "replace_only",
+ "result" => ["\\inputencoding " . $inputEncoding->{out}]);
+ push(@rElems, $inputenc);
+ }
setMatching(\@rElems);
return(1);
}
"search" => '^\\\\(photo|ecvpicture)(.*\{)(.*)\}',
"fileidx" => 3,
"result" => ["\\", "1", "2", "3", "}"]);
- setMatching([$rElem]);
+ #
+ # Remove comments from preamble
+ my $comments = newMatch("search" => '^([^%]*)([%]+)([^%]*)$',
+ "filetype" => "replace_only",
+ "result" => ["1", "2"]);
+ setMatching([$rElem, $comments]);
return(1);
}
return(0);
{
my ($l) = @_;
- if ($l =~ /^\\begin_layout\s+(.+)$/) {
+ if ($l =~ /^\\begin_layout\s+(.*)$/) {
#print "started layout\n";
my %selem = ();
$selem{type} = "layout";