sub getFileIdx($);
sub getExt($);
sub getResult($);
-sub checkForHeader($);
+sub checkForHeader($$);
sub checkForPreamble($);
sub checkForLayoutStart($);
sub checkForInsetStart($);
sub checkForLatexCommand($);
-sub checkLyxLine($);
+sub checkLyxLine($$);
my @stack = (); # list of HASH-Arrays
my $rFont = {};
my $useNonTexFont = "true";
my $inputEncoding = undef;
+my $sysdir = undef;
# The elements are:
# type (layout, inset, header, preamble, ...)
sub initLyxStack($$$)
{
+ use Cwd 'abs_path';
+
$rFont = $_[0];
if ($_[1] eq "systemF") {
$useNonTexFont = "true";
$inputEncoding = $_[2];
}
$stack[0] = { type => "Starting"};
+ my $p = abs_path( __FILE__ );
+ $p =~ s/\/development\/autotests\/.*$/\/lib/;
+ # Save the value to be used as replacement for systemlyxdir in \origin statements
+ $sysdir = $p;
+ # print "Sysdir set to $sysdir\n";
}
sub diestack($)
return($m->{"result"});
}
-sub checkForHeader($)
+sub checkForHeader($$)
{
- my ($l) = @_;
+ my ($l, $sourcedir) = @_;
if ($l =~ /^\\begin_header\s*$/) {
my %selem = ();
"result" => ["\\inputencoding " . $inputEncoding->{out}]);
push(@rElems, $inputenc);
}
+ my $origin = newMatch("search" => qr/^\\origin\s+(\/systemlyxdir)(.*)$/,
+ "filetype" => "replace_only",
+ "result" => ["\\origin $sysdir", "2"]);
+ push(@rElems, $origin);
+ my $originu = newMatch("search" => qr/^\\origin\s+unavailable/,
+ "filetype" => "replace_only",
+ "result" => ["\\origin $sourcedir"]);
+ push(@rElems, $originu);
setMatching(\@rElems);
return(1);
}
if ($param eq "bibtex") {
my $rElem1 = newMatch("ext" => ".bib",
"filetype" => "prefix_for_list",
- "search" => qr/^bibfiles\s+\"(.+)\"/,
+ "search" => qr/^bibfiles\s+\"([^\"]+)\"/,
"result" => ["bibfiles \"", "1", "\""]);
my $rElem2 = newMatch("ext" => ".bst",
"filetype" => "prefix_for_list",
# separator: to be used while concatenating the filenames
# filetype: prefix_only,replace_only,copy_only,interpret
# same as before, but without 'prefix_for_list'
-sub checkLyxLine($)
+sub checkLyxLine($$)
{
- my ($l) = @_;
+ my ($l, $sourcedir) = @_;
- return({"found" => 0}) if (checkForHeader($l));
+ return({"found" => 0}) if (checkForHeader($l, $sourcedir));
return({"found" => 0}) if (checkForPreamble($l));
return({"found" => 0}) if (checkForEndBlock($l));
return({"found" => 0}) if (checkForLayoutStart($l));