[xml/sgml-commit] [SCM] linuxdoc-tools package for Debian. branch, experimental, updated. debian/0.9.50-10-g3b6c937

Agustin Martin Domingo agmartin at debian.org
Sun Jun 15 23:35:41 UTC 2008


The following commit has been merged in the experimental branch:
commit fe98977b3bc59ca84bbb5fac258b884dae9336a9
Author: Agustin Martin Domingo <agmartin at debian.org>
Date:   Mon Jun 16 00:40:25 2008 +0200

    Better postASP support for non verbatim in tscreen. More checks in preASP.
    
    We want to support things like
    
    <tscreen><verb>
    I am a <tt/verbatim/ line
    </verb>
    I am not a <tt/verbatim/ line
    </tscreen>
    
    Since nsgmls will break lines when look changing commands are found in
    tscreen+non-verbatim, we need to make sure that LyX-Code commands are
    not sent neither during the look change nor in the line after it. No
    problem in verbatim+tscreen, since lines will not be broken.
    
    We use $inlookchange to signal this, 0 or undefined means no look change,
    1 means in look change and 2 means last line ended a look change.

diff --git a/lib/dist/fmt_lyx.pl b/lib/dist/fmt_lyx.pl
index 2254cf0..ad10632 100644
--- a/lib/dist/fmt_lyx.pl
+++ b/lib/dist/fmt_lyx.pl
@@ -36,6 +36,7 @@ my $lyx_escape = sub {
 # -----------------------------------------------------------------------
     my ($data) = @_;
 
+    # The single exception backslash is treated below
     return ($data);
 };
 
@@ -46,7 +47,8 @@ $lyx->{preASP} = sub {
 #  Note that currently LyX works only with isolatin1
 # -----------------------------------------------------------------------
   my ($INFILE, $OUTFILE) = @_;
-  # The single exception backslash is treated bellow
+  my $verbatim;
+  my $inheading;
 
   # `sdata_dirs' list is passed as anonymous array to make a single argument
   my $char_maps = load_char_maps ('.2l1b', [ Text::EntityMap::sdata_dirs() ]);
@@ -61,7 +63,7 @@ $lyx->{preASP} = sub {
     s/\\\|refnam\\\|/ /g;
 
     if ( s/^-// ) {
-      print $OUTFILE "-" . &parse_data($_, $char_maps, $lyx_escape) . "\n";
+      print $OUTFILE "-" . parse_data($_, $char_maps, $lyx_escape) . "\n";
     } elsif (/^A/) {
       /^A(\S+) (IMPLIED|CDATA|NOTATION|ENTITY|TOKEN)( (.*))?$/
 	|| die "bad attribute data: $_\n";
@@ -72,6 +74,15 @@ $lyx->{preASP} = sub {
       }
       print $OUTFILE "A$name $type $value\n";
     } else {
+      if (/^\(HEADING/){
+        $inheading = 1;
+      } elsif (/^\)HEADING/){
+        $inheading = '';
+      } elsif (/^\((VERB|CODE)/) {
+	$verbatim = 1;
+      } elsif (/^\)(VERB|CODE)/) {
+	$verbatim = '';
+      }
       print $OUTFILE $_ . "\n";
     }
   }
@@ -91,6 +102,7 @@ $lyx->{postASP} = sub {
   my $indent_level   = -1;
   my $verb_last_line = "";
   my $verbatim       = 0;
+  my $inlookchange;
   my $inheading;
   my $initem;
   my $intag;
@@ -181,26 +193,42 @@ $lyx->{postASP} = sub {
     } elsif ( /^\@\/verb\@/ ) {
       $verbatim = 0;
     } else {
-      $inheading = 0 if ( /^\\layout Standard/ );
-      $intt      = 0 if ( /^\\family default.*$/ );
-      $inheading = 1 if ( /^\\layout (Part|Chapter|.*section|.*paragraph)/ );
-      $intt      = 1 if ( /^\\family typewriter.*$/ );
+      $inheading    = 1 if ( /^\\layout (Part|Chapter|.*section|.*paragraph)/ );
+      $inlookchange = 1 if ( m/^\\(family|series|shape)/ && ! m/default/ );
+      $intt         = 1 if ( /^\\family typewriter.*$/ );
 
       # For LyX file clarity
       s/\\backslash/\n\\backslash\n/g unless ( $verbatim or $inheading or $intt);
-      s/\s+/ /g unless ( $verbatim or $intt );
+      s/\s+/ /g unless ( $verbatim or $intt or $tscreen );
 
       if ( $intag ) {
 	s/\s+/\n\\protected_separator\n/g unless m/^\\(family|series|shape)/;
       } elsif ( $tscreen ) {
-	# If verbatim, lines are not split when things like <tt/../ appears.
-	$_ = "\\layout LyX-Code\n$_" unless ( $intt
-					      or m/^\\(family|layout|series|shape)/
-					      or m/^[$nbsp\s]*$/ );
+	if ( $verbatim ) {
+	  # If verbatim, there are no line breaks when things like <tt/../ appears.
+	  $_ = "\\layout LyX-Code\n$_";
+	} else {
+	  # We do not want to have LyX-Code commands when line breaks are caused by
+	  # look changing commands like \family .... This also applies to the line
+	  # after \... default (so the $inlookchange == 2 hack below.)
+	  $_ = "\\layout LyX-Code\n$_" unless $inlookchange;
+	}
       } elsif ( $inheading) {
 	s/\s+/ /g;
       }
 
+      $inheading      = 0 if ( /^\\layout Standard/ );
+
+      if ( /^\\family default.*$/ ) {
+	$intt         = 0;
+	# Signal for next line processing that this is an end-look-change command
+	$inlookchange = 2;
+      } elsif ( $inlookchange == 2 ) {
+	# Line previous to this one was an end-look-change command
+	$inlookchange = 0;
+      }
+
+
       $lyxout .= "$_\n";
     }
   }

-- 
linuxdoc-tools package for Debian.



More information about the debian-xml-sgml-commit mailing list