--- loncom/xml/londefdef.pm 2005/09/19 10:59:08 1.286 +++ loncom/xml/londefdef.pm 2005/09/22 10:27:25 1.287 @@ -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 @@ BEGIN { } + sub initialize_londefdef { $Apache::londefdef::TD_redirection=0; @Apache::londefdef::table = (); @@ -1206,6 +1207,9 @@ sub start_br { } 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 @@ sub start_img { $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 @@ sub LATEX_length { } +# 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;