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

sakharuk lon-capa-cvs@mail.lon-capa.org
Thu, 10 Apr 2003 14:31:09 -0000


sakharuk		Thu Apr 10 10:31:09 2003 EDT

  Modified files:              
    /loncom/xml	londefdef.pm 
  Log:
  Completely rewritten latex output code for <hr> tag. New parameter TeXwidth is introduced to specify the lengh of the line. Align parameter is now supported .
  
  
  
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.123 loncom/xml/londefdef.pm:1.124
--- loncom/xml/londefdef.pm:1.123	Wed Mar 19 11:50:14 2003
+++ loncom/xml/londefdef.pm	Thu Apr 10 10:31:09 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.123 2003/03/19 16:50:14 www Exp $
+# $Id: londefdef.pm,v 1.124 2003/04/10 14:31:09 sakharuk Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -46,7 +46,7 @@
 
 use Apache::lonnet();
 use strict;
-use Apache::lonxml();
+use Apache::lonxml;
 use Apache::File();
 use Image::Magick;
 use Apache::lonmenu();
@@ -1202,12 +1202,31 @@
 
 #-- <hr> tag
 sub start_hr {
-    my ($target,$token) = @_;
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';
     if ($target eq 'web') {
 	$currentstring .= $token->[4];
     } elsif ($target eq 'tex') {
-	$currentstring .= '\vskip 0 mm \noindent\makebox[\textwidth/2 ][b]{\hrulefill}\vskip 0 mm ';
+	my $LaTeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval);
+	if (defined $LaTeXwidth) {
+	    if ($LaTeXwidth=~/^%/) {
+		substr($LaTeXwidth,0,1)='';
+		$LaTeXwidth=($LaTeXwidth/100).'\textwidth';
+	    }
+	} else {
+	    $LaTeXwidth ='0.95\textwidth';
+	}
+	my ($pre,$post);
+	my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
+	if (($align eq 'center') || (not defined $align)) {
+	    $pre=''; $post='';
+	} elsif ($align eq 'left') {
+	    $pre='\rlap{'; $post='} \hfill';
+	} elsif ($align eq 'right') {
+	    $pre=' \hfill \llap{'; $post='}';
+	}
+	$currentstring .= ' \vskip 0 mm \noindent\makebox[\textwidth]{'.$pre.'\makebox['.
+                                    $LaTeXwidth.'][b]{\hrulefill}'.$post.'}\vskip 0 mm ';
     } 
     return $currentstring;
 }