[EMAIL PROTECTED] (Lars Gullik Bjønnes) writes:

| Can some of you relyx people have a look at case 638 and see if this
| patch has any relevance?
| 
| It kindo seems that it fixes things, but I won't apply anything until
| I have confirmations.

? relyx.diff
Index: BasicLyX.pm
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/reLyX/BasicLyX.pm,v
retrieving revision 1.5
diff -u -p -r1.5 BasicLyX.pm
--- BasicLyX.pm	7 Jan 2003 14:30:52 -0000	1.5
+++ BasicLyX.pm	19 Jan 2003 11:05:59 -0000
@@ -185,13 +185,13 @@ my %TextTransTable = (
 # E.g., \ref{foo} ->'\begin_inset LatexCommand \ref{foo}\n\n\end_inset \n'
 # (Some take arguments, others don't)
 my @LatexCommands = map {"\\$_"} qw(ref pageref label cite bibliography
-	                         index printindex tableofcontents
-                                 listofalgorithms listoftables listoffigures);
+				 index printindex tableofcontents
+				 listofalgorithms listoftables listoffigures);
 my @IncludeCommands = map {"\\$_"} qw(input include);
 # Included postscript files
 # LyX 1.0 can't do \includegraphics*!
 my @GraphicsCommands = map {"\\$_"} qw(epsf epsffile epsfbox
-                                       psfig epsfig includegraphics);
+				       psfig epsfig includegraphics);
 
 # Accents. Most of these take an argument -- the thing to accent
 # (\l and \L are handled as InsetLatexAccents, so they go here too)
@@ -238,7 +238,7 @@ sub call_parser {
     #    Type=>report_args and count=>1
     # Note that we don't have to bother putting in tokens which will be simply
     #    translated (e.g., from %TextTokenTransTable).
-    my %MyTokens = ( 
+    my %MyTokens = (
 	'{' => $Text::TeX::Tokens{'{'},
 	'}' => $Text::TeX::Tokens{'}'},
 	'\begin' => $Text::TeX::Tokens{'\begin'},
@@ -264,7 +264,7 @@ sub call_parser {
 	# Just pretend they actually ARE new paragraph markers!
 	'\maketitle' => {'class' => 'Text::TeX::Paragraph'},
     );
-    
+
     # Now add to MyTokens all of the commands that were read from the
     #    commands file by package ReadCommands
     &ReadCommands::Merge(\%MyTokens);
@@ -311,8 +311,8 @@ sub basic_lyx {
     #    (2) allows us to use things like next and last
     TYPESW: for ($type) {
 
-        # some pre-case work
-        s/^Text::TeX:://o or die "unknown token?!";
+	# some pre-case work
+	s/^Text::TeX:://o or die "unknown token?!";
 	my ($dummy, $tok);
 	my ($thistable);
 
@@ -332,8 +332,8 @@ sub basic_lyx {
 	    }
 	}
 
-        # Handle blank lines.
-        if (m/^Paragraph$/o) {
+	# Handle blank lines.
+	if (m/^Paragraph$/o) {
 	    # $INP <>0 means We will need a new layout command
 	    $IsNewParagraph = 1;
 
@@ -341,22 +341,22 @@ sub basic_lyx {
 	    #    unless there's an \item command
 	    $MayBeDeeper = 1;
 
-            last TYPESW;
-        }
+	    last TYPESW;
+	}
 
 	# If, e.g., there's just a comment in this token, don't do anything
 	# This actually shouldn't happen if CleanTeX has already removed them
 	last TYPESW if !defined $eaten->print;
-        
-        # Handle LaTeX tokens
-        if (/^Token$/o) {
+
+	# Handle LaTeX tokens
+	if (/^Token$/o) {
 
 	    my $name = $eaten->token_name; # name of the token, e.g., "\large"
 	    print "'$name' " if $debug_on;
 
 	    # Tokens which turn into a bit of LyX text
 	    if (exists $TextTokenTransTable{$name}) {
-	        &CheckForNewParagraph; #Start new paragraph if necessary
+		&CheckForNewParagraph; #Start new paragraph if necessary
 
 		my $to_print = $TextTokenTransTable{$name};
 
@@ -383,8 +383,8 @@ sub basic_lyx {
 	    # Handle tokens that LyX translates as a "LatexCommand" inset
 	    } elsif (grep {$_ eq $name} @LatexCommands) {
 		&CheckForNewParagraph; #Start new paragraph if necessary
-	        print OUTFILE "$pre_space\n\\begin_inset LatexCommand ",
-		               $name,
+		print OUTFILE "$pre_space\n\\begin_inset LatexCommand ",
+			       $name,
 			      "\n\n\\end_inset \n\n";
 
 	    # Math -- copy verbatim until you're done
@@ -400,13 +400,13 @@ sub basic_lyx {
 		print OUTFILE $dummy;
 
 	    } elsif ($name eq '\)' || $name eq '\]') {
-	        # end math
+		# end math
 		print OUTFILE "$name\n\\end_inset \n\n";
 		print "\nDone copying math ending with '$name'" if $debug_on;
 
 	    # Items in list environments
 	    } elsif ($name eq '\item') {
-		
+
 		# What if we had a nested "Standard" paragraph?
 		# Then write \end_deeper to finish the standard layout
 		#     before we write the new \layout ListEnv command
@@ -414,10 +414,10 @@ sub basic_lyx {
 		    pop (@$CurrentLayoutStack); # take "Standard" off the stack
 		    print OUTFILE "\n\\end_deeper ";
 		    print "\nCurrent Layout Stack: @$CurrentLayoutStack"
-		          if $debug_on;
+			  if $debug_on;
 		} # end deeper if
 
-		# Upcoming text (the item) will be a new paragraph, 
+		# Upcoming text (the item) will be a new paragraph,
 		#    requiring a new layout command based on whichever
 		#    kind of list environment we're in
 		$IsNewParagraph = 1;
@@ -472,7 +472,7 @@ sub basic_lyx {
 
 	    } elsif ($name eq '\\\\' || $name eq '\\newline' || $name eq "\\tabularnewline") {
 		&CheckForNewParagraph; # could be at beginning of par?
-                print OUTFILE "\n\\newline \n";
+		print OUTFILE "\n\\newline \n";
 
 		# If we're in a table, \\ means add a row to the table
 		# Note: if we're on the last row of the table, this extra
@@ -493,7 +493,7 @@ sub basic_lyx {
 	    } elsif ($name =~ /^\\epsf[xy]size$/) {
 		# We need to eat '=' followed by EITHER more text OR
 		# one (or more?!) macros describing a TeX size
-	        my $arg = $fileobject->eatMultiToken;
+		my $arg = $fileobject->eatMultiToken;
 		my $length = $arg->print;
 		$length =~ s/^\s*=\s*// or warn "weird '$name' command!";
 
@@ -508,13 +508,13 @@ sub basic_lyx {
 		$length =~ s/\s*$//; # may have \n at end
 
 		# If we can't parse the command, print it in tex mode
-		&RelyxFigure::parse_epsfsize($name, $length) or 
+		&RelyxFigure::parse_epsfsize($name, $length) or
 		    &print_tex_mode("$name=$length");
 
 	    # Miscellaneous...
 
 	    } elsif ($name =~ /\\verb.*?/) {
-	        my $dummy = &Verbatim::copy_verb($fileobject, $eaten);
+		my $dummy = &Verbatim::copy_verb($fileobject, $eaten);
 		print "\nCopying $name in TeX mode: " if $debug_on;
 		&print_tex_mode ($dummy);
 
@@ -528,9 +528,9 @@ sub basic_lyx {
 		}
 	    }
 
-            last TYPESW;
-        }
-        
+	    last TYPESW;
+	}
+
 	# Handle tokens that take arguments, like \section{},\section*{}
 	if (/^BegArgsToken$/) {
 	    my $name = $eaten->token_name;
@@ -540,7 +540,7 @@ sub basic_lyx {
 	    if (grep {$_ eq $name} @LatexCommands) {
 		&CheckForNewParagraph; #Start new paragraph if necessary
 
-	        print OUTFILE "$pre_space\n\\begin_inset LatexCommand ";
+		print OUTFILE "$pre_space\n\\begin_inset LatexCommand ";
 
 		#    \bibliography gets handled as a LatexCommand inset, but
 		# it's a special case, cuz LyX syntax expects "\BibTeX"
@@ -566,13 +566,13 @@ sub basic_lyx {
 		}
 
 		print OUTFILE "\{";
-	        last TYPESW; # skip to the end of the switch
+		last TYPESW; # skip to the end of the switch
 	    }
 
 	    if (grep {$_ eq $name} @IncludeCommands) {
 		&CheckForNewParagraph; #Start new paragraph if necessary
-	        print OUTFILE "$pre_space\n$Begin_Inset_Include $name\{";
-	        last TYPESW; # skip to the end of the switch
+		print OUTFILE "$pre_space\n$Begin_Inset_Include $name\{";
+		last TYPESW; # skip to the end of the switch
 	    }
 
 	    # This is to handle cases where _ is used, say, in a filename.
@@ -593,11 +593,11 @@ sub basic_lyx {
 	    # Font characteristics
 	    } elsif (exists $FontTransTable{$name}) {
 		my $dum2;
-	        my $command = $FontTransTable{$name};
-	        ($dummy, $dum2) = ($command =~ /(\S+)\s+(\w+)/);
+		my $command = $FontTransTable{$name};
+		($dummy, $dum2) = ($command =~ /(\S+)\s+(\w+)/);
 
 		# HACK so that "\emph{hi \emph{bye}}" yields unemph'ed "bye"
-		if ( ($dummy eq "\\emph") && 
+		if ( ($dummy eq "\\emph") &&
 		     ($CurrentFontStatus->{$dummy}->[-1] eq "on")) {
 		       $dum2 = "default"; # "on" instead of default?
 		       $command =~ s/on/default/;
@@ -615,16 +615,16 @@ sub basic_lyx {
 
 
 	    # Handle footnotes and margin notes
-	    # Make a new font table & layout stack which will be local to the 
+	    # Make a new font table & layout stack which will be local to the
 	    #    footnote or marginpar
 	    } elsif (exists $FloatTransTable{$name}) {
-	        my $command = $FloatTransTable{$name};
+		my $command = $FloatTransTable{$name};
 
 		# Open the footnote
 		print OUTFILE "$pre_space$command";
 
 		# Make $CurrentFontStatus point to a new (anonymous) font table
-	        $CurrentFontStatus =  {
+		$CurrentFontStatus =  {
 		    '\emph' => ["default"],
 		    '\family' => ["default"],
 		    '\series' => ["default"],
@@ -638,7 +638,7 @@ sub basic_lyx {
 		$CurrentLayoutStack = ["Standard"];
 
 		# Store whether we're at the end of a paragraph or not
-		#    for when we get to end of footnote AND 
+		#    for when we get to end of footnote AND
 		# Note that the footnote text will be starting a new paragraph
 		# Also store the current alignment (justification)
 		$OldINP = $IsNewParagraph; $OldMBD = $MayBeDeeper;
@@ -652,7 +652,7 @@ sub basic_lyx {
 		&CheckForNewParagraph; # may be at the beginning of a par
 
 		print OUTFILE "$pre_space\n",'\i ',$name,'{'
-	    
+
 	    # Included Postscript Figures
 	    # Currently, all postscript including commands take one
 	    # required argument and 0 to 2 optional args, so we can
@@ -664,7 +664,7 @@ sub basic_lyx {
 		my $arg2 = $fileobject->eatOptionalArgument;
 		my $arg3 = $fileobject->eatRequiredArgument;
 		my $save = $arg1->exact_print . $arg2->exact_print .
-		           $arg3->exact_print;
+			   $arg3->exact_print;
 
 		# Parse and put figure into LyX file
 		# Print it verbatim if we didn't parse correctly
@@ -715,7 +715,7 @@ sub basic_lyx {
 		&CheckForNewParagraph;
 
 		$tok = $fileobject->eatOptionalArgument;
-	        print OUTFILE "$name ", $tok->exact_print, "{";
+		print OUTFILE "$name ", $tok->exact_print, "{";
 
 	    # Miscellaneous
 
@@ -734,7 +734,7 @@ sub basic_lyx {
 		print $dummy if $debug_on;
 		print OUTFILE $dummy;
 
-	        # end math
+		# end math
 		print OUTFILE "\\)\n\\end_inset \n\n";
 		print "\nDone copying math" if $debug_on;
 
@@ -755,7 +755,7 @@ sub basic_lyx {
 	    if ($eaten->base_token == $tok) {
 		&copy_latex_known($eaten,$fileobject);
 	    }
-        
+
 	    last TYPESW;
 	}
 
@@ -764,7 +764,7 @@ sub basic_lyx {
 	    my $tok = $tex_mode_tokens[-1] || 0;
 	    if ($eaten->base_token eq $tok) {
 		&copy_latex_known($eaten,$fileobject);
-	        last TYPESW;
+		last TYPESW;
 	    }
 
 	    my $name = $eaten->token_name;
@@ -773,7 +773,7 @@ sub basic_lyx {
 	    # Handle things that LyX translates as a "LatexCommand" inset
 	    # or "Include" insets
 	    if (grep {$_ eq $name} @LatexCommands, @IncludeCommands) {
-	        print OUTFILE "\}\n\n\\end_inset \n\n";
+		print OUTFILE "\}\n\n\\end_inset \n\n";
 
 	    } elsif (exists $ReadCommands::ToLayout->{$name}) {
 		&EndLayout($name);
@@ -782,15 +782,15 @@ sub basic_lyx {
 	    # Pop the current FontStatus stack for a given characteristic
 	    #    and give the new command (e.g., \emph default)
 	    } elsif (exists $FontTransTable{$name}) {
-	        my $command = $FontTransTable{$name};
-	        ($dummy) = ($command =~ /(\S+)\s+\w+/);
+		my $command = $FontTransTable{$name};
+		($dummy) = ($command =~ /(\S+)\s+\w+/);
 		pop @{$CurrentFontStatus->{$dummy}};
 		$command = "\n$dummy $CurrentFontStatus->{$dummy}->[-1] \n";
 		print OUTFILE "$command";
 
 	    # Footnotes and marginpars
 	    } elsif (exists $FloatTransTable{$name}) {
-	        print OUTFILE "\n\\end_float \n\n";
+		print OUTFILE "\n\\end_float \n\n";
 
 		# Reset the layout stack and font status table pointers to
 		#    point to the global stack/table again, instead of the
@@ -811,9 +811,9 @@ sub basic_lyx {
 
 	    } elsif ($name =~ m/^$AccentTokens$/) {
 		print OUTFILE "}\n";
-	    
+
 	    } elsif ($name eq "\\bibitem") {
-	        print OUTFILE "}\n";
+		print OUTFILE "}\n";
 	    } # End if on $name
 
 	    # Exit main switch
@@ -840,7 +840,7 @@ sub basic_lyx {
 		print OUTFILE "$command";
 
 	    } else {
-	        warn "Unknown EndLocal token!\n";
+		warn "Unknown EndLocal token!\n";
 	    }
 
 	    last TYPESW;
@@ -859,14 +859,14 @@ sub basic_lyx {
 	    last TYPESW;
 	}
 
-        # Handle \begin{foo}
-        if (/^Begin::Group::Args$/) {
+	# Handle \begin{foo}
+	if (/^Begin::Group::Args$/) {
 	    print $eaten->print," " if $debug_on; # the string "\begin{foo}"
 	    my $env = $eaten->environment;
-	    
+
 	    # Any environment found in the layouts files
 	    if (exists $ReadCommands::ToLayout->{$env}) {
-	        &ConvertToLayout($env);
+		&ConvertToLayout($env);
 
 		# Some environments have an extra argument. In that case,
 		# print the \layout command (cuz these environments always
@@ -892,7 +892,7 @@ sub basic_lyx {
 		&CheckForNewParagraph; # may be beginning of paragraph
 		my $begin_text = $eaten->print;
 		print "\nCopying math beginning with '$begin_text'\n"
-		                                              if $debug_on;
+							      if $debug_on;
 		print OUTFILE "\n\\begin_inset Formula $begin_text ";
 		$dummy = &Verbatim::copy_verbatim($fileobject, $eaten);
 		$dummy = &fixmath($dummy); # convert '\sp' to '^', etc.
@@ -902,7 +902,7 @@ sub basic_lyx {
 	    # Alignment environments
 	    } elsif (exists $AlignEnvironments{$env}) {
 		# Set it to the command which creates this alignment
-	        $CurrentAlignment = $AlignEnvironments{$env};
+		$CurrentAlignment = $AlignEnvironments{$env};
 		($dummy) = ($CurrentAlignment =~ /\S+\s+(\w+)/);
 		print "\nNow $dummy-aligning text " if $debug_on;
 
@@ -919,7 +919,7 @@ sub basic_lyx {
 		if ($tok && defined ($dummy = $tok->print) && $dummy) {
 		    print "\nIgnoring float placement '$dummy'" if $debug_on;
 		}
-	        my $command = $FloatEnvTransTable{$env};
+		my $command = $FloatEnvTransTable{$env};
 
 		# Open the table/figure
 		print OUTFILE "$command";
@@ -942,7 +942,7 @@ sub basic_lyx {
 		    print "\nIgnoring positioning arg '$dummy'" if $debug_on;
 		}
 
-	        # Read the argument into a TT::Group
+		# Read the argument into a TT::Group
 		#   (that group may contain groups, e.g. for {clp{10cm}}
 		$tok = $fileobject->eatGroup;
 		new RelyxTable::Table $tok;
@@ -950,14 +950,14 @@ sub basic_lyx {
 	    # \begin document
 	    } elsif ($env eq "document") {
 		# do nothing
-	        #print "\nStarting to translate actual document" if $debug_on;
+		#print "\nStarting to translate actual document" if $debug_on;
 
 	    # Special environments to copy as regular text (-r option).
 	    # Do this by copying the \begin & \end command in TeX mode
 	    # (\Q\E around $env allows *'s in environment names!)
 	    } elsif (grep /^\Q$env\E$/, @ReadCommands::regular_env) {
 		print "\nCopying $env environment as regular text\n"
-		                                              if $debug_on;
+							      if $debug_on;
 		$dummy = $eaten->print; # \begin{env}, ignore initial whitespace
 		&print_tex_mode($dummy);
 
@@ -971,23 +971,23 @@ sub basic_lyx {
 		$tex_mode_string = "";
 		# print "\begin{env}
 		# For reLyXskip env, don't print the \begin & \end commands!
-		$tex_mode_string .= $eaten->exact_print 
-		                unless $env eq "reLyXskip";
+		$tex_mode_string .= $eaten->exact_print
+				unless $env eq "reLyXskip";
 		$tex_mode_string .=&Verbatim::copy_verbatim($fileobject,$eaten);
 	    }
 
-            last TYPESW;
-        }
-        
-        # Handle \end{foo}
-        if (/^End::Group::Args$/) {
+	    last TYPESW;
+	}
+
+	# Handle \end{foo}
+	if (/^End::Group::Args$/) {
 	    print $eaten->print," " if $debug_on; # the string "\end{foo}"
 	    my $env = $eaten->environment;
 
 	    # End of list or quote/verse environment
 	    # OR special environment given with -t option
 	    if (exists $ReadCommands::ToLayout->{$env}) {
-	        &EndLayout($env);
+		&EndLayout($env);
 		$item_preface = ""; # reset when at end of List env.
 
 	    # End of math environments
@@ -997,7 +997,7 @@ sub basic_lyx {
 
 	    } elsif (exists $AlignEnvironments{$env}) {
 		# Back to block alignment
-	        $CurrentAlignment = "";
+		$CurrentAlignment = "";
 		print "\nBack to block alignment" if $debug_on;
 
 		# assume that \end should end a paragraph
@@ -1006,11 +1006,11 @@ sub basic_lyx {
 
 	    # Environments lyx translates to floats
 	    } elsif (exists $FloatEnvTransTable{$env}) {
-	        print OUTFILE "\n\\end_float \n\n";
+		print OUTFILE "\n\\end_float \n\n";
 
 	    # table
 	    } elsif ($env =~ /tabular$/) { # don't allow tabular*
-	        if ($thistable = &RelyxTable::in_table) {
+		if ($thistable = &RelyxTable::in_table) {
 		    $thistable->done_reading;
 		    print OUTFILE "\n$RelyxTable::TableEndString\n";
 		} else {warn "found \\end{tabular} when not in table!"}
@@ -1019,7 +1019,7 @@ sub basic_lyx {
 		$IsNewParagraph = 1; $MayBeDeeper = 1;
 
 	    } elsif ($env eq "document") {
-	        print "\nDone with document!" if $debug_on;
+		print "\nDone with document!" if $debug_on;
 
 	    # "regular" environment given with -r option
 	    } elsif (grep /^\Q$env\E$/, @ReadCommands::regular_env) {
@@ -1034,15 +1034,15 @@ sub basic_lyx {
 		# Add \end{env} (including initial whitespace) to string
 		# For reLyXskip environment, don't print \begin & \end commands!
 		$tex_mode_string .= $eaten->exact_print
-		                       unless $env eq "reLyXskip";
+				       unless $env eq "reLyXskip";
 		# Now print it
 		&print_tex_mode($tex_mode_string);
 		print "Done copying unknown environment '$env'" if $debug_on;
 	    }
 
-            last TYPESW;
+	    last TYPESW;
 
-        }
+	}
 
 	# Note for text handling: we have to do lots of stuff to handle
 	# spaces in (as close as possible to) the same way that LaTeX does
@@ -1121,7 +1121,7 @@ sub basic_lyx {
 	    # - before first space after column seventy-one
 	    # - after 80'th column
 	    while (1) {
-	        $outstr =~ s/\. (?!$)/.\n /      or
+		$outstr =~ s/\. (?!$)/.\n /      or
 		$outstr =~ s/(.{71,79}?) /$1\n / or
 		$outstr =~ s/(.{80})(.)/$1\n$2/ or
 		last; # exit loop if string is < 79 characters
@@ -1158,7 +1158,7 @@ sub copy_latex_unknown {
     #    We can't use copy_verbatim (unless we make it smarter) because
     # it would choke on nested braces
     print "\nUnknown token: '",$eaten->print,"': Copying in TeX mode\n"
-                                                         if $debug_on;
+							 if $debug_on;
     my $dum2;
     while (($dum2 = $fileobject->lookAheadToken) &&
 	   ($dum2 =~ /^[[{]$/)) {
@@ -1168,7 +1168,7 @@ sub copy_latex_unknown {
 	} else {
 	    $count = 0;
 	    EAT: { #copied from eatBalanced, but allow paragraphs
-	        die unless defined ($tok = $fileobject->eatMultiToken);
+		die unless defined ($tok = $fileobject->eatMultiToken);
 		$outstr.="\n",redo EAT if ref($tok) eq "Text::TeX::Paragraph";
 		$dummy = $tok->exact_print;
 		$outstr .= $dummy;
@@ -1212,7 +1212,7 @@ sub copy_latex_known {
 # Initialize tex mode copying
     if ($type eq "BegArgsToken" or $type eq "Token") {
 	print "\nCopying untranslatable token '",$eaten->print,
-	                              "' in TeX mode" if $debug_on;
+				      "' in TeX mode" if $debug_on;
 	push @tex_mode_tokens, $temp_start;
 
 	# initialize the string of stuff we're copying
@@ -1267,8 +1267,8 @@ sub copy_latex_known {
 	# and \foo{bar} yield \foobar in the LaTeX files created by LyX
 	my $dummy;
 	if ($type eq "Token" and
-	        $dummy=$fileobject->lookAheadToken and
-	        $dummy =~ /[{}]/)
+		$dummy=$fileobject->lookAheadToken and
+		$dummy =~ /[{}]/)
 	{
 	    $tex_mode_string .= '{}';
 	}
@@ -1278,13 +1278,13 @@ sub copy_latex_known {
 	&print_tex_mode($tex_mode_string);
 	$tex_mode_string = "";
 
-        # We're done with this token
+	# We're done with this token
 	pop(@tex_mode_tokens);
 
 	my $i = $type eq "Token" ? "" : " and its arguments";
 	my $j = $temp_start->print;
 	print "\nDone copying untranslatable token '$j'$i in TeX mode"
-	                                                  if $debug_on;
+							  if $debug_on;
     } # end tex copying?
 } # end sub copy_latex_known
 
@@ -1304,10 +1304,10 @@ sub print_tex_mode {
     # Handle extra \n's (& spaces) at beginning & end of string
     my $str_ends_par = ($outstr =~ s/\n{2,}$//);
     if ($IsNewParagraph) {
-        $outstr =~ s/^\s+//;  # .e.g, $outstr follows '\begin{quote}'
+	$outstr =~ s/^\s+//;  # .e.g, $outstr follows '\begin{quote}'
     } else {
 	# Any whitespace is equivalent to one space in LaTeX
-        $outstr =~ s/^\s+/ /; # e.g. $outstr follows "\LaTeX{}" or "Hi{}"
+	$outstr =~ s/^\s+/ /; # e.g. $outstr follows "\LaTeX{}" or "Hi{}"
     }
 
     # Check whether string came right at the beginning of a new paragraph
@@ -1344,7 +1344,7 @@ sub CheckForNewParagraph {
 # If $CurrentAlignment is set, it prints the alignment command for this par.
 # If $MayBeDeeper==1 and we're currently within a list environment,
 #    it starts a "deeper" Standard paragraph
-    my $dummy; 
+    my $dummy;
     my $layout = $$CurrentLayoutStack[-1];
 
     return if &RelyxTable::in_table;
@@ -1355,7 +1355,7 @@ sub CheckForNewParagraph {
 	    if ($layout =~ /^$ListLayouts$/o) {
 		push (@$CurrentLayoutStack, "Standard");
 		print "\nCurrent Layout Stack: @$CurrentLayoutStack\n"
-		                                     if $debug_on;
+						     if $debug_on;
 		print OUTFILE "\n\\begin_deeper ";
 		$layout = "Standard";
 	    }
@@ -1400,7 +1400,8 @@ sub ConvertToLayout {
     print "\nChanging $dummy $name to layout $layout" if $debug_on;
 
     # Nest if the layout stack has more than just "Standard" in it
-    if ($#{$CurrentLayoutStack} > 0) {
+    if ($#{$CurrentLayoutStack} > 0
+	&& $CurrentLayoutStack =~ /^$ListLayouts$/o) {
 	# Die here for sections & things that can't be nested!
 	print " Nesting!" if $debug_on;
 	print OUTFILE "\n\\begin_deeper ";
@@ -1474,7 +1475,8 @@ sub EndLayout {
     #     \end_deeper \begin_deeper in the LyX file. It's sloppy
     #     but it works, and LyX will get rid of it when it
     #     resaves the file.
-    if ($#{$CurrentLayoutStack} > 0) {
+    if ($#{$CurrentLayoutStack} > 0
+	&& $CurrentLayoutStack =~ /^$ListLayouts$/o) {
 	print " End Nesting!" if $debug_on;
 	print OUTFILE "\n\\end_deeper ";
     }
@@ -1496,10 +1498,10 @@ sub fixmath {
     while ($input =~ s/
 	    (.*?)    # non-token matter ($1)
 	    (\\      # token ($2) is a backslash followed by ...
-	        ( ([^A-Za-z] \*?) |    # non-letter (and *) ($4) OR
+		( ([^A-Za-z] \*?) |    # non-letter (and *) ($4) OR
 		  ([A-Za-z]+ \*?)   )  # letters (and *) ($5)
 	    )//xs) # /x to allow whitespace/comments, /s to copy \n's
-    { 
+    {
 	$output .= $1;
 	my $tok = $2;
 	if (exists $ReadCommands::math_trans{$tok}) {
@@ -1507,7 +1509,7 @@ sub fixmath {
 	    # add ' ' in case we had, e.g., \|a, which would become \Verta
 	    # Only need to do it in those special cases
 	    $tok .= ' ' if
-	            defined $4 && $tok =~ /[A-Za-z]$/ && $input =~ /^[A-Za-z]/;
+		    defined $4 && $tok =~ /[A-Za-z]$/ && $input =~ /^[A-Za-z]/;
 	}
 	$output .= $tok;
     }
@@ -1517,4 +1519,3 @@ sub fixmath {
 }
 
 1; # return true to calling subroutine
-
-- 
        Lgb

Reply via email to