version 1.460, 2016/08/09 23:43:38
|
version 1.465, 2020/09/10 00:28:48
|
Line 98 sub start_m {
|
Line 98 sub start_m {
|
# On top of that, MathJax will render math without $, but |
# On top of that, MathJax will render math without $, but |
# it will fail with tth. This is worth a warning. |
# it will fail with tth. This is worth a warning. |
# (even though some people might just use latex for printing) |
# (even though some people might just use latex for printing) |
&Apache::lonxml::warning(&mt("Missing \$ in <m>.")); |
&Apache::lonxml::warning(&mt('Missing $ in [_1].','<m>')); |
} |
} |
my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval); |
my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval); |
if ($eval eq 'on') { |
if ($eval eq 'on') { |
Line 826 sub end_h1 {
|
Line 826 sub end_h1 {
|
$currentstring .= $token->[2]; |
$currentstring .= $token->[2]; |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
my $post='\vskip 0 mm '; |
my $post='\vskip 0 mm '; |
my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); |
my $align=lc(&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1)); |
if ($align eq 'center') { |
if ($align eq 'center') { |
$post='\end{center}'; |
$post='\end{center}'; |
} elsif ($align eq 'left') { |
} elsif ($align eq 'left') { |
Line 1305 sub start_p {
|
Line 1305 sub start_p {
|
|
|
$currentstring .= &end_p(); # close off prior para if in progress. |
$currentstring .= &end_p(); # close off prior para if in progress. |
my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); |
my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); |
|
if (!defined $align) { |
|
# check inline CSS |
|
$align = &get_css_property('text-align',$parstack,$safeeval); |
|
} |
if ($align eq 'center') { |
if ($align eq 'center') { |
$currentstring .='\begin{center}\par '; |
$currentstring .='\begin{center}\par '; |
$closing_string = '\end{center}'; |
$closing_string = '\end{center}'; |
Line 1312 sub start_p {
|
Line 1316 sub start_p {
|
$currentstring = ¢er_correction().$currentstring; |
$currentstring = ¢er_correction().$currentstring; |
} |
} |
} elsif ($align eq 'right') { |
} elsif ($align eq 'right') { |
$currentstring.="\n".'{\flushright '; |
$currentstring.="\n".'\begin{flushright}'; |
# $currentstring.='\makebox['.$env{'form.textwidth'}.']{\hfill\llap{'; |
# $currentstring.='\makebox['.$env{'form.textwidth'}.']{\hfill\llap{'; |
$closing_string= "}\n"; |
$closing_string= '\end{flushright}'."\n"; |
} elsif ($align eq 'left') { |
} elsif ($align eq 'left') { |
$currentstring.= "\n".'{\flushleft '; |
$currentstring.= "\n".'\begin{flushleft}'; |
# $currentstring.='\noindent\makebox['.$env{'form.textwidth'}.']{{'; |
# $currentstring.='\noindent\makebox['.$env{'form.textwidth'}.']{{'; |
$closing_string = "}\n"; |
$closing_string = '\end{flushleft}'."\n"; |
} else { |
} else { |
$currentstring.='\par '; |
$currentstring.='\par '; |
if (&is_inside_of($tagstack, 'table')) { |
if (&is_inside_of($tagstack, 'table')) { |
Line 4053 sub end_spacer {
|
Line 4057 sub end_spacer {
|
return $currentstring; |
return $currentstring; |
} |
} |
|
|
|
my @span_end_stack; # for span tex target |
|
|
#-- <span> tag (end tag required) |
#-- <span> tag (end tag required) |
sub start_span { |
sub start_span { |
my ($target,$token) = @_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; |
my $currentstring = ''; |
my $currentstring = ''; |
if ($target eq 'web' || $target eq 'webgrade') { |
if ($target eq 'web' || $target eq 'webgrade') { |
$currentstring = $token->[4]; |
$currentstring = $token->[4]; |
} |
} elsif ($target eq 'tex') { |
|
my $endstring = ''; |
|
my $family = &get_css_property('font-family',$parstack,$safeeval); |
|
if ($family eq 'monospace') { |
|
$currentstring .= '\texttt{'; |
|
$endstring .= '}'; |
|
} |
|
my $weight = &get_css_property('font-weight',$parstack,$safeeval); |
|
if ($weight eq 'bold') { |
|
$currentstring .= '\textbf{'; |
|
$endstring .= '}'; |
|
} |
|
my $style = &get_css_property('font-style',$parstack,$safeeval); |
|
if ($style eq 'italic') { |
|
$currentstring .= '\textit{'; |
|
$endstring .= '}'; |
|
} |
|
push(@span_end_stack, $endstring); |
|
} |
return $currentstring; |
return $currentstring; |
} |
} |
|
|
Line 4068 sub end_span {
|
Line 4092 sub end_span {
|
my $currentstring = ''; |
my $currentstring = ''; |
if ($target eq 'web' || $target eq 'webgrade') { |
if ($target eq 'web' || $target eq 'webgrade') { |
$currentstring = $token->[2]; |
$currentstring = $token->[2]; |
} |
} elsif ($target eq 'tex') { |
|
my $endstring = pop @span_end_stack; |
|
$currentstring .= $endstring; |
|
} |
return $currentstring; |
return $currentstring; |
} |
} |
|
|
Line 4568 sub latex_header {
|
Line 4595 sub latex_header {
|
($mode eq 'batchmode')) {$currentstring .='\batchmode';} |
($mode eq 'batchmode')) {$currentstring .='\batchmode';} |
$currentstring .= '\newcommand{\keephidden}[1]{}'. |
$currentstring .= '\newcommand{\keephidden}[1]{}'. |
'\renewcommand{\deg}{$^{\circ}$}'. |
'\renewcommand{\deg}{$^{\circ}$}'. |
'\usepackage{multirow}'. |
'\usepackage{multirow}'."\n". |
'\usepackage{longtable}'. |
'\usepackage{longtable}'."\n". |
'\usepackage{textcomp}'. |
'\usepackage{textcomp}'."\n". |
'\usepackage{makeidx}'. |
'\usepackage{makeidx}'."\n". |
'\usepackage[dvips]{graphicx}'. |
'\usepackage[dvips]{graphicx}'."\n". |
'\usepackage{wrapfig}'. |
'\usepackage{wrapfig}'."\n". |
'\usepackage{picins}'. |
'\usepackage{picins}'."\n". |
'\usepackage[T1]{fontenc}'."\n". |
'\usepackage[T1]{fontenc}'."\n". |
'\usepackage{lmodern}'."\n". |
'\usepackage{lmodern}'."\n". |
'\usepackage[postscript]{ucs}'."\n". |
'\usepackage[postscript]{ucs}'."\n". |
'\usepackage[utf8x]{inputenc}'."\n". |
'\usepackage[utf8x]{inputenc}'."\n". |
'\usepackage{pifont}' ."\n". |
'\usepackage{pifont}'."\n". |
'\usepackage{latexsym}'."\n". |
'\usepackage{latexsym}'."\n". |
'\usepackage{epsfig}'. |
'\usepackage{epsfig}'."\n". |
"\\usepackage{xtab}\n". |
'\usepackage{xtab}'."\n". |
"\\usepackage{tabularx}\n". |
'\usepackage{tabularx}'."\n". |
"\\usepackage{booktabs}\n". |
'\usepackage{booktabs}'."\n". |
"\\usepackage{array}\n". |
'\usepackage{array}'."\n". |
"\\usepackage{colortbl}\n". |
'\usepackage{colortbl}'."\n". |
"\\usepackage{xcolor}\n". |
'\usepackage{xcolor}'."\n". |
'\usepackage{calc}'. |
'\usepackage{calc}'."\n". |
'\usepackage{amsmath}'. |
'\usepackage{amsmath}'."\n". |
'\usepackage{soul}'. |
'\usepackage{soul}'."\n". |
'\usepackage{amssymb}'. |
'\usepackage{amssymb}'."\n". |
'\usepackage{amsfonts}'. |
'\usepackage{amsfonts}'."\n". |
'\usepackage{amsthm}'. |
'\usepackage{amsthm}'."\n". |
'\usepackage{amscd}' |
'\usepackage{amscd}'."\n". |
.'\usepackage{picins}\usepackage{calc}'."\n". # From lonprintout.pm |
'\usepackage{actuarialangle}'."\n"; |
'\usepackage[T1]{fontenc}'."\n". |
|
'\usepackage{lmodern}'."\n". |
|
'\usepackage[postscript]{ucs}'."\n". |
|
'\usepackage[utf8x]{inputenc}'."\n". |
|
'\usepackage{pifont}' . "\n"; |
|
|
|
if($env{'form.pdfFormFields'} eq 'yes') { |
if($env{'form.pdfFormFields'} eq 'yes') { |
$currentstring .= '\usepackage{hyperref}'. |
$currentstring .= '\usepackage{hyperref}'. |
'\usepackage{eforms}'. |
'\usepackage{eforms}'. |
Line 4672 sub clean_docs_httpref {
|
Line 4693 sub clean_docs_httpref {
|
return $cleanhref; |
return $cleanhref; |
} |
} |
|
|
|
# This is retrieving a CSS property from the style attribute of the current element. |
|
# It is not checking <style> elements or linked stylesheets yet. |
|
sub get_css_property { |
|
my ($property,$parstack,$safeeval) = @_; |
|
my $style=&Apache::lonxml::get_param('style',$parstack,$safeeval,undef,1); |
|
my @style_components=split(/;/,$style); |
|
foreach my $css_pair (@style_components) { |
|
my ($name, $value) = split(/:/, $css_pair); |
|
$name =~ s/^\s+|\s+$//g; |
|
$value =~ s/^\s+|\s+$//g; |
|
if ($name eq $property) { |
|
return $value; |
|
} |
|
} |
|
return undef; |
|
} |
|
|
=pod |
=pod |
|
|
=head1 NAME |
=head1 NAME |