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

foxr lon-capa-cvs@mail.lon-capa.org
Thu, 22 Sep 2005 10:27:27 -0000


foxr		Thu Sep 22 06:27:27 2005 EDT

  Modified files:              
    /loncom/xml	londefdef.pm 
  Log:
  Sense presence in the table in tex mode and force default img wrapping to a horizontal
  one to activate the wrap tex rendering.
  
  
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.286 loncom/xml/londefdef.pm:1.287
--- loncom/xml/londefdef.pm:1.286	Mon Sep 19 06:59:08 2005
+++ loncom/xml/londefdef.pm	Thu Sep 22 06:27:25 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.286 2005/09/19 10:59:08 foxr Exp $
+# $Id: londefdef.pm,v 1.287 2005/09/22 10:27:25 foxr Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -55,6 +55,7 @@
 
 }
 
+
 sub initialize_londefdef {
     $Apache::londefdef::TD_redirection=0;
     @Apache::londefdef::table = ();
@@ -1206,6 +1207,9 @@
     } elsif ($target eq 'tex') {
 	my @tempo=@$tagstack;
 	my $signal=0;
+	#  Not going to factor this to is_inside_of since that would require
+        #  multiple stack traversals.
+	#
 	for (my $i=$#tempo;$i>=0;$i--) {
 	    if (($tempo[$i] eq 'b') || ($tempo[$i] eq 'strong') ||
                 ($tempo[$i] eq 'ol') || ($tempo[$i] eq 'ul') ||
@@ -2560,7 +2564,11 @@
 						  $safeeval,
 						  undef,1));
 	if(!$align) {
-	    $align = "bottom";	# This is html's default so it's ours too.
+	    if (&is_inside_of($tagstack, "table")) {
+		$align = "right";      # Force wraptext use. 
+	    } else {
+		$align = "bottom";	# This is html's default so it's ours too.
+	    }
 	}
 	#
 	&Apache::lonxml::debug("Alignemnt = $align");
@@ -4091,6 +4099,26 @@
 }
 
 
+# is_inside_of $tagstack $tag
+#    This sub returns true if the current state of Xml processing
+#    is inside of the tag.   
+# Parameters:
+#     tagstack   - The tagstack from the parser.
+#     tag        - The tag (without the <>'s.).
+# Sample usage:
+#     if (is_inside_of($tagstack "table")) {
+#          # I'm in a table....
+#      }
+sub is_inside_of {
+    my ($tagstack, $tag) = @_;
+    my @stack = @$tagstack;
+    for (my $i = ($#stack - 1); $i >= 0; $i--) {
+	if ($stack[$i] eq $tag) {
+	    return 1;
+	}
+    }
+    return 0;
+}
 
 
 1;