[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:42 UTC 2008


The following commit has been merged in the experimental branch:
commit 6c3453185744832121665eea168e95ff4bd438a5
Author: Agustin Martin Domingo <agmartin at debian.org>
Date:   Mon Jun 16 01:17:29 2008 +0200

    Better postASP tscreen support using LyX-Code. More checks in preASP.
    
    * Use Lyx-Code more extensively. Do not use begin/end_deeper
    * Better postASP support for non verbatim in tscreen.
    
        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 7ca7c76..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;
@@ -172,11 +184,8 @@ $lyx->{postASP} = sub {
     } # tscreen
     elsif( /^\@tscreen\@/ ) {
       $tscreen = 1;
-      $lyxout .= "\\begin_deeper\n";
-      $lyxout .= "\\layout Standard\n"
-      } elsif ( /^\@\/tscreen\@/ ) {
+    } elsif ( /^\@\/tscreen\@/ ) {
       $tscreen = 0;
-      $lyxout .= "\\end_deeper\n";
       $lyxout .= "\\layout Standard\n";
     } # Verbatim
     elsif( /^\@verb\@/ ) {
@@ -184,23 +193,41 @@ $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)/ );
+      $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 ( $verbatim ) {
-	$_ = "\\layout LyX-Code\n$_";
+      } elsif ( $tscreen ) {
+	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 = 1 if ( /^\\layout (Part|Chapter|.*section|.*paragraph)/ );
-      $intt      = 1 if ( /^\\family typewriter.*$/ );
+      $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