[LON-CAPA-cvs] cvs: loncom /xml londefdef.pm

sakharuk lon-capa-cvs@mail.lon-capa.org
Thu, 19 Feb 2004 19:34:09 -0000


sakharuk		Thu Feb 19 14:34:09 2004 EDT

  Modified files:              
    /loncom/xml	londefdef.pm 
  Log:
  Bug 2749 is fixed. Now you can use attribute allign="center|left|right" in <p>
  tag. But for attribute values "left|right" there are severe limitations: you can not put <br /> tag inside paragraph (this comes from LaTeX limitations).
  
  
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.197 loncom/xml/londefdef.pm:1.198
--- loncom/xml/londefdef.pm:1.197	Fri Jan 30 12:31:06 2004
+++ loncom/xml/londefdef.pm	Thu Feb 19 14:34:09 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.197 2004/01/30 17:31:06 sakharuk Exp $
+# $Id: londefdef.pm,v 1.198 2004/02/19 19:34:09 sakharuk Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -1099,24 +1099,45 @@
 }
 
 #-- <p> tag (end tag optional)
+#optional attribute - align="center|left|right"
 sub start_p {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';
     if ($target eq 'web') {
 	$currentstring .= $token->[4];
     } elsif ($target eq 'tex') {
-	my $signal=1;
-	foreach my $tag (@$tagstack) {if (lc($tag) eq 'b') {$signal=0;}}
-	if ($signal) {$currentstring .= '\par ';}
+	my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
+	if ($align eq 'center') {
+	    $currentstring='\begin{center}\par';
+	} elsif ($align eq 'right') {
+	    $currentstring='\makebox['.$ENV{'form.textwidth'}.']{\hfill\llap{';
+	} elsif ($align eq 'left') {
+	    $currentstring='\noindent\makebox['.$ENV{'form.textwidth'}.']{\rlap{';
+	}
+	my $signal=1;#<p> does not work inside <b>...</b> 
+	foreach my $tag (@$tagstack) {if (lc($tag) eq 'b') {$signal=0;}
+	if (!$signal) {$currentstring = '';}
+	}
     }
     return $currentstring;
 }
 
 sub end_p {
-    my ($target,$token) = @_;
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';
     if ($target eq 'web') {
 	$currentstring .= $token->[2];
+    } elsif ($target eq 'tex') {
+	if ($$tagstack[-1] eq 'p') {
+	    my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
+	    if ($align eq 'center') {		
+		$currentstring .= '\end{center}';
+	    } elsif ($align eq 'right') {
+		$currentstring .= '}}';
+	    } elsif ($align eq 'left') {
+		$currentstring .= '}\hfill}';
+	    }
+	}
     }
     return $currentstring;
 }