');
$Apache::lontexconvert::errorstring='';
}
#&Apache::lonxml::debug("M is ends with:$currentstring:");
$Apache::lonxml::post_evaluate=0;
} elsif ($target eq 'tex') {
+
$currentstring = $inside;
my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval);
if ($eval eq 'on') {
$currentstring=&Apache::run::evaluate($currentstring,$safeeval,$$parstack[-1]);
}
if ($currentstring=~/^(\s*\\\\\s*)*$/) {$currentstring = ' \vskip 0 mm ';}
+ # detect simple math mode entry exits, and convert them
+ # to use \ensuremath ... unless there's a \verb inside.
+ if (! ($currentstring=~/\\verb/)) {
+ if ($currentstring=~/^\s*\$[^\$].*\$\s*$/) {
+ $currentstring=~s/^(\s*)\$/$1/;
+ $currentstring=~s/\$(\s*)$/$1/;
+ $currentstring='\ensuremath{'.$currentstring.'}';
+ }
+ }
$Apache::lonxml::post_evaluate=0;
}
return $currentstring;
@@ -123,12 +149,13 @@ sub end_m {
}
sub start_tthoption {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
my $result;
- if ($target eq 'web') {
- my $inside = &Apache::lonxml::get_all_text("/tthoption",$parser);
+ if ($target eq 'web' || $target eq 'webgrade') {
+ my $inside = &Apache::lonxml::get_all_text("/tthoption",$parser,
+ $style);
$inside=~s/^\s*//;
- if ($ENV{'browser.mathml'}) {
+ if ($env{'browser.mathml'}) {
&tth::ttmoptions($inside);
} else {
&tth::tthoptions($inside);
@@ -147,39 +174,20 @@ sub end_tthoption {
sub start_html {
my ($target,$token) = @_;
my $currentstring = '';
- my $options=$ENV{'course.'.$ENV{'request.course.id'}.'.tthoptions'};
- &Apache::lontexconvert::init_tth();
- if ($target eq 'web' || $target eq 'edit') {
- $currentstring = &Apache::lonxml::xmlbegin().
- &Apache::lonxml::fontsettings();
- } elsif ($target eq 'tex') {
- @Apache::londefdef::table = ();
- $currentstring .= '\documentclass[letterpaper]{article}';
- if ($ENV{'form.latex_type'}=~'batchmode') {$currentstring .='\batchmode';}
- $currentstring .= '\newcommand{\keephidden}[1]{}'.
- '\renewcommand{\deg}{$^{\circ}$}'.
- '\usepackage{longtable}'.
- '\usepackage{textcomp}'.
- '\usepackage{makeidx}'.
- '\usepackage[dvips]{graphicx}'.
- '\usepackage{epsfig}'.
- '\usepackage{calc}'.
- '\usepackage{amsmath}'.
- '\usepackage{amssymb}'.
- '\usepackage{amsfonts}'.
- '\usepackage{amsthm}'.
- '\usepackage{amscd}'.
- '\newenvironment{choicelist}{\begin{list}{}{\setlength{\rightmargin}{0in}\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.05in}\setlength{\itemsep}{0.022in}\setlength{\parsep}{0in}\setlength{\belowdisplayskip}{0.04in}\setlength{\abovedisplayskip}{0.05in}\setlength{\abovedisplayshortskip}{-0.04in}\setlength{\belowdisplayshortskip}{0.04in}}}{\end{list}}'.
- '\renewenvironment{theindex}{\begin{list}{}{{\vskip 1mm \noindent \large\textbf{Index}} \newline \setlength{\rightmargin}{0in}\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.01in}\setlength{\itemsep}{0.1in}\setlength{\parsep}{-0.02in}\setlength{\belowdisplayskip}{0.01in}\setlength{\abovedisplayskip}{0.01in}\setlength{\abovedisplayshortskip}{-0.04in}\setlength{\belowdisplayshortskip}{0.01in}}}{\end{list}}';
+ if ($target eq 'web' || $target eq 'edit' || $target eq 'webgrade' ) {
+ # start_body() takes care of emitting the
+ } elsif ($target eq 'tex') {
+
+ $currentstring .= &latex_header();
}
return $currentstring;
}
sub end_html {
- my ($target,$token) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
- if ($target eq 'web') {
- $currentstring = &Apache::lonxml::xmlend();
+ if ($target eq 'web' || $target eq 'webgrade') {
+ # end_body takes care of the
}
return $currentstring;
}
@@ -188,8 +196,8 @@ sub end_html {
sub start_head {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
- $currentstring = $token->[4];
+ if ($target eq 'web' || $target eq 'webgrade') {
+ &Apache::lonxml::startredirection();
}
return $currentstring;
}
@@ -197,9 +205,12 @@ sub start_head {
sub end_head {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web' && $ENV{'request.state'} eq 'published') {
- $currentstring = &Apache::lonmenu::registerurl(undef,$target).
- $token->[2];
+ if (($target eq 'web' && $env{'request.state'} eq 'published') ||
+ ($target eq 'webgrade' && $env{'request.state'} eq 'published')) {
+ # in case there is a but no
+ if ($Apache::lonxml::redirection) {
+ $Apache::londefdef::head = &Apache::lonxml::endredirection();
+ }
}
return $currentstring;
}
@@ -208,7 +219,7 @@ sub end_head {
sub start_map {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[4];
}
return $currentstring;
@@ -217,7 +228,7 @@ sub start_map {
sub end_map {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[2];
}
return $currentstring;
@@ -227,7 +238,7 @@ sub end_map {
sub start_select {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
$Apache::londefdef::select=0;
@@ -238,7 +249,7 @@ sub start_select {
sub end_select {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[2];
}
return $currentstring;
@@ -248,7 +259,7 @@ sub end_select {
sub start_option {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
$Apache::londefdef::select++;
@@ -264,7 +275,7 @@ sub start_option {
sub end_option {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
$currentstring='}';
@@ -276,7 +287,7 @@ sub end_option {
sub start_input {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[4];
}
return $currentstring;
@@ -285,7 +296,7 @@ sub start_input {
sub end_input {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[2];
}
return $currentstring;
@@ -295,7 +306,7 @@ sub end_input {
sub start_textarea {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[4];
}
return $currentstring;
@@ -304,7 +315,7 @@ sub start_textarea {
sub end_textarea {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[2];
}
return $currentstring;
@@ -314,7 +325,7 @@ sub end_textarea {
sub start_form {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[4];
}
return $currentstring;
@@ -323,7 +334,7 @@ sub start_form {
sub end_form {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[2];
}
return $currentstring;
@@ -331,10 +342,11 @@ sub end_form {
#-- tag (end tag required)
sub start_title {
- my ($target,$token) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
my $currentstring = '';
- if ($target eq 'web') {
- $currentstring = $token->[4];
+ if ($target eq 'web' || $target eq 'webgrade') {
+ $Apache::londefdef::title =
+ &Apache::lonxml::get_all_text('/title',$parser,$style);
} elsif ($target eq 'tex') {
$currentstring .= '\keephidden{Title of the document: '
}
@@ -348,8 +360,8 @@ sub start_title {
sub end_title {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
- $currentstring = $token->[2];
+ if ($target eq 'web' || $target eq 'webgrade') {
+ # start_title takes care of swallowing the title
} elsif ($target eq 'tex') {
$currentstring .= '}';
}
@@ -362,13 +374,13 @@ sub end_title {
#-- tag (end tag forbidden)
sub start_meta {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
my $args='';
if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
if ($args eq '') {
- &Apache::lonxml::get_all_text("/meta",$parser);
+ &Apache::lonxml::get_all_text("/meta",$parser,$style);
} else {
$currentstring = $token->[4];
}
@@ -406,6 +418,16 @@ sub start_meta {
if ((not defined $content) && (not defined $name)) {
&Apache::lonxml::startredirection();
}
+ } elsif ($target eq 'edit') {
+ $currentstring .= &Apache::edit::tag_start($target,$token);
+ $currentstring .= &Apache::edit::text_arg('Name:','name',$token,30);
+ $currentstring .= &Apache::edit::text_arg('Content:','content',$token,70);
+ $currentstring .= &Apache::edit::end_row();
+ } elsif ($target eq 'modified') {
+ my $constructtag =
+ &Apache::edit::get_new_args($token,$parstack,$safeeval,
+ 'name','content');
+ if ($constructtag) { $currentstring = &Apache::edit::rebuild_tag($token); }
}
return $currentstring;
}
@@ -413,7 +435,7 @@ sub start_meta {
sub end_meta {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
my $args='';
if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
if ($args ne '') {
@@ -429,34 +451,49 @@ sub end_meta {
return $currentstring;
}
+sub insert_meta {
+ return '
+ ';
+}
+
# accessrule
sub start_accessrule {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
my $currentstring = '';
- my $eff=&Apache::lonxml::get_param
- ('effect',$parstack,$safeeval,undef,1);
- my $realm=&Apache::lonxml::get_param
- ('realm',$parstack,$safeeval,undef,1);
- my $role=&Apache::lonxml::get_param
- ('role',$parstack,$safeeval,undef,1);
- $realm=~s/\s+//g;
- $realm=~s/\//\_/g;
- $realm=~s/^\_//;
- $realm=~s/\W/\;/g;
- $role=~s/\s+//g;
- $role=~s/\//\_/g;
- $role=~s/\W/\;/g;
+ my $eff =&Apache::lonxml::get_param('effect',$parstack,$safeeval,undef,1);
+ my $realm=&Apache::lonxml::get_param('realm', $parstack,$safeeval,undef,1);
+ my $role =&Apache::lonxml::get_param('role', $parstack,$safeeval,undef,1);
+ my $type =&Apache::lonxml::get_param('type', $parstack,$safeeval,undef,1);
+
+ my ($dom,$crs,$sec,$separator);
+ if ($type eq 'user') {
+ ($dom,$crs,$sec)=split(m{/},$realm);
+ $crs = &LONCAPA::clean_username($crs);
+ $separator = '/';
+ } else {
+ ($dom,$crs,$sec)=split(/\_/,$realm);
+ $crs = &LONCAPA::clean_courseid($crs);
+ $separator = '_';
+ }
+ $dom = &LONCAPA::clean_domain($dom);
+
+ $sec =~s/\W//;
+ $realm = $dom;
+ if ($crs =~ /\S/) { $realm .= $separator.$crs; }
+ if ($sec =~ /\S/) { $realm .= $separator.$sec; }
+ $role=~s/\W//g;
+
if ($target eq 'web') {
my $args='';
if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
if ($args eq '') {
- &Apache::lonxml::get_all_text("/accessrule",$parser);
+ &Apache::lonxml::get_all_text("/accessrule",$parser,$style);
} else {
$currentstring = $token->[4];
}
}
if ($target eq 'meta') {
- $currentstring=''.$eff.':'.$realm.':'.$role.'';
+ $currentstring=''.$eff.':'.$realm.':'.$role.':'.$type.'';
}
return $currentstring;
}
@@ -474,124 +511,168 @@ sub end_accessrule {
return $currentstring;
}
+sub generate_css_links {
+ my $links;
+ my $css_href = &Apache::lonnet::EXT('resource.0.cssfile');
+ if ($css_href =~ /\S/) {
+ &Apache::lonxml::extlink($css_href);
+ $links .=
+ '';
+ }
+ return $links;
+}
+
#-- tag (end tag required)
sub start_body {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+
+ if ($target eq 'web' || $target eq 'webgrade') {
if ($Apache::lonhomework::parsing_a_problem) {
&Apache::lonxml::warning(" tag found inside of tag this can cause problems.");
return '';
}
- if (!$Apache::lonxml::registered &&
- $ENV{'request.state'} eq 'published') {
- $currentstring.=''.
- &Apache::lonmenu::registerurl(undef,$target).'';
- }
-# Accessibility
- if ($ENV{'browser.imagesuppress'} eq 'on') {
- delete($token->[2]->{'background'});
- }
- if ($ENV{'browser.fontenhance'} eq 'on') {
- my $style='';
- foreach my $key (keys(%{$token->[2]})) {
- if ($key =~ /^style$/i) {
- $style.=$token->[2]->{$key}.';';
- delete($token->[2]->{$key});
- }
- }
- $token->[2]->{'style'}=$style.'; font-size: x-large;';
- }
- if ($ENV{'browser.blackwhite'} eq 'on') {
- delete($token->[2]->{'font'});
- delete($token->[2]->{'link'});
- delete($token->[2]->{'alink'});
- delete($token->[2]->{'vlink'});
- delete($token->[2]->{'bgcolor'});
- delete($token->[2]->{'background'});
- }
-# Overload loads
- my $onLoad='';
- foreach my $key (keys(%{$token->[2]})) {
- if ($key =~ /^onload$/i) {
- $onLoad.=$token->[2]->{$key}.';';
- delete($token->[2]->{$key});
- }
- }
- $token->[2]->{'onload'}=&Apache::lonmenu::loadevents().';'.$onLoad;
- my $onUnload='';
- foreach my $key (keys(%{$token->[2]})) {
- if ($key =~ /^onunload$/i) {
- $onUnload.=$token->[2]->{$key}.';';
- delete($token->[2]->{$key});
- }
- }
- $token->[2]->{'onunload'}=&Apache::lonmenu::unloadevents().
- ';'.$onUnload;
- $currentstring .= '<'.$token->[1];
- foreach (keys %{$token->[2]}) {
- $currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"';
- }
- $currentstring.='>';
- if ($ENV{'request.state'} ne 'published') {
- $currentstring.=(<
-
-
-EDITBUTTON
- } else {
- $currentstring.=&Apache::lonmenu::menubuttons(undef,$target,1);
+ if (&is_inside_of($tagstack, "head")) {
+ &end_head(@_);
}
- $currentstring.=&Apache::lonxml::message_location();
+
+ my $extra_head = &generate_css_links();
+
+ # Breadcrumbs
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ if ($env{'request.state'} eq 'construct') {
+ &Apache::lonhtmlcommon::add_breadcrumb({
+ 'text' => 'Construction Space',
+ 'href' => &Apache::loncommon::authorspace(),
+ });
+ &Apache::lonhtmlcommon::add_breadcrumb({
+ 'text' => 'HTML Editor',
+ 'href' => '',
+ });
+ # breadcrumbs (and tools) will be created
+ # in start_page->bodytag->innerregister
+ } else {
+ # FIXME Where are we?
+ }
+
+ $currentstring =
+ &Apache::loncommon::start_page($Apache::londefdef::title,
+ $Apache::londefdef::head
+ .$extra_head,
+ {'add_entries' => $token->[2],
+# 'no_title' => 1,
+ 'force_register' => 1});
+
+ my $header = '';
+ if ($env{'request.state'} ne 'published' &&
+ $env{'request.state'} ne 'construct') {
+ $header=&Apache::lonmenu::constspaceform();
+ }
+ if ($env{'request.state'} ne 'published') {
+ $header.=&Apache::londefdef::edit_controls();
+ }
+ if ($env{'request.state'} eq 'construct') {
+ $currentstring.=&Apache::loncommon::head_subbox(
+ &Apache::loncommon::CSTR_pageheader()
+ .$header);
+ } elsif ($env{'request.state'} eq 'edit') {
+ $currentstring.=&Apache::loncommon::head_subbox($header);
+ }
+ $currentstring.=&Apache::lonxml::message_location();
} elsif ($target eq 'tex') {
- $currentstring = '\begin{document}';
- }
+ $currentstring = ''; # '\begin{document}' is in header.
+ }
+
return $currentstring;
}
+sub edit_controls {
+ my ($nochgview) = @_;
+ my $result .= '
+
+';
+ return $result;
+}
+
sub end_body {
- my ($target,$token) = @_;
- my $currentstring = '';
- if ($target eq 'web') {
- $currentstring = $token->[2];
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
+ my $currentstring = &end_p(); # Close off unclosed
+ if ($target eq 'web' || $target eq 'webgrade') {
+ $currentstring .= &Apache::loncommon::end_page({'discussion' => 1});
} elsif ($target eq 'tex') {
- $currentstring = '\strut\newline\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\newline\noindent \end{document}';
+ $currentstring .= '\strut\newline\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\newline\noindent \end{document}';
}
return $currentstring;
}
+# \begin{center} causes a new paragprah spacing that looks odd inside
+# of a table cell. Same at the end of a \center but with a slightly
+# larger space .. hence center_correction and center_end_correction.
+#
+sub center_correction { return '\vspace*{-6 mm}'; }
+sub center_end_correction { return '\vspace*{-7 mm}'; }
+
#--
tag (end tag required)
sub start_center {
- my ($target,$token) = @_;
- my $currentstring = '';
- if ($target eq 'web') {
- $currentstring = $token->[4];
+ my ($target,$token,$tagstack) = @_;
+ my $currentstring = &end_p(); # Close off any prior para.
+ if ($target eq 'web' || $target eq 'webgrade') {
+ $currentstring .= $token->[4];
} elsif ($target eq 'tex') {
- $currentstring = '\begin{center}';
+ if (&is_inside_of($tagstack, "table")) {
+ $currentstring .= ¢er_correction();
+ }
+ $currentstring .= '\begin{center}';
}
return $currentstring;
}
sub end_center {
- my ($target,$token) = @_;
+ my ($target,$token,$tagstack) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
$currentstring = '\end{center}';
+ if (&is_inside_of($tagstack, "table")) {
+ $currentstring .= ¢er_end_correction();
+ }
}
return $currentstring;
}
#-- tag (end tag required)
+# NOTE: In TeX mode disables internal
sub start_b {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
- $currentstring = '\textbf{';
+ &disable_para();
+ $currentstring .= '\textbf{';
}
return $currentstring;
}
@@ -599,21 +680,24 @@ sub start_b {
sub end_b {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
- $currentstring = '}';
+ &enable_para();
+ $currentstring = '}';
}
return $currentstring;
}
#-- tag (end tag required)
+# NOTE: in TeX mode disables internal
sub start_strong {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
+ &disable_para();
$currentstring = '\textbf{';
}
return $currentstring;
@@ -622,9 +706,10 @@ sub start_strong {
sub end_strong {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
+ &enable_para();
$currentstring = '}';
}
return $currentstring;
@@ -633,8 +718,8 @@ sub end_strong {
#--
tag (end tag required)
sub start_h1 {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
- my $currentstring = '';
- if ($target eq 'web') {
+ my $currentstring = &end_p(); # Close off any prior para.
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
my $pre;
@@ -648,9 +733,9 @@ sub start_h1 {
}
my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
if (not defined $TeXsize) {$TeXsize="large";}
- $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{';
+ $currentstring .= '\strut\newline '.$pre.'{\\'.$TeXsize.' \textbf{';
} elsif ($target eq 'meta') {
- $currentstring='';
+ $currentstring.='';
&start_output($target);
}
return $currentstring;
@@ -659,7 +744,7 @@ sub start_h1 {
sub end_h1 {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
my $post='\vskip 0 mm ';
@@ -682,8 +767,8 @@ sub end_h1 {
#--
tag
sub start_h2 {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
- my $currentstring = '';
- if ($target eq 'web') {
+ my $currentstring = &end_p(); # Close off any prior para.
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
my $pre;
@@ -697,7 +782,7 @@ sub start_h2 {
}
my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
if (not defined $TeXsize) {$TeXsize="large";}
- $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{';
+ $currentstring .= '\strut\newline '.$pre.'{\\'.$TeXsize.' \textbf{';
}
return $currentstring;
}
@@ -705,7 +790,7 @@ sub start_h2 {
sub end_h2 {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
my $post='\vskip 0 mm ';
@@ -725,8 +810,8 @@ sub end_h2 {
#--
tag
sub start_h3 {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
- my $currentstring = '';
- if ($target eq 'web') {
+ my $currentstring = &end_p(); # Close off any prior para.
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
my $pre;
@@ -740,7 +825,7 @@ sub start_h3 {
}
my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
if (not defined $TeXsize) {$TeXsize="large";}
- $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{';
+ $currentstring .= '\strut\newline '.$pre.'{\\'.$TeXsize.' \textbf{';
}
return $currentstring;
}
@@ -748,7 +833,7 @@ sub start_h3 {
sub end_h3 {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
my $post='\vskip 0 mm ';
@@ -768,8 +853,8 @@ sub end_h3 {
#--
tag
sub start_h4 {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
- my $currentstring = '';
- if ($target eq 'web') {
+ my $currentstring = &end_p(); # Close off any prior para.
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
my $pre;
@@ -783,7 +868,7 @@ sub start_h4 {
}
my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
if (not defined $TeXsize) {$TeXsize="large";}
- $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{';
+ $currentstring .= '\strut\newline '.$pre.'{\\'.$TeXsize.' \textbf{';
}
return $currentstring;
}
@@ -791,7 +876,7 @@ sub start_h4 {
sub end_h4 {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
my $post='\vskip 0 mm ';
@@ -811,8 +896,8 @@ sub end_h4 {
#--
tag
sub start_h5 {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
- my $currentstring = '';
- if ($target eq 'web') {
+ my $currentstring = &end_p(); # Close off any prior paras.
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
my $pre;
@@ -826,7 +911,7 @@ sub start_h5 {
}
my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
if (not defined $TeXsize) {$TeXsize="large";}
- $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{';
+ $currentstring .= '\strut\newline '.$pre.'{\\'.$TeXsize.' \textbf{';
}
return $currentstring;
}
@@ -834,7 +919,7 @@ sub start_h5 {
sub end_h5 {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
my $post='\vskip 0 mm ';
@@ -854,8 +939,8 @@ sub end_h5 {
#--
tag
sub start_h6 {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
- my $currentstring = '';
- if ($target eq 'web') {
+ my $currentstring = &end_p(); # Close off any prior paras.
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
my $pre;
@@ -869,7 +954,7 @@ sub start_h6 {
}
my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0);
if (not defined $TeXsize) {$TeXsize="large";}
- $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{';
+ $currentstring .= '\strut\newline '.$pre.'{\\'.$TeXsize.' \textbf{';
}
return $currentstring;
}
@@ -877,7 +962,7 @@ sub start_h6 {
sub end_h6 {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
my $post='\vskip 0 mm ';
@@ -898,7 +983,7 @@ sub end_h6 {
sub start_cite {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
$currentstring .= '\textit{';
@@ -909,7 +994,7 @@ sub start_cite {
sub end_cite {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
$currentstring .= '}';
@@ -921,7 +1006,7 @@ sub end_cite {
sub start_i {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
$currentstring .= '\textit{';
@@ -932,7 +1017,7 @@ sub start_i {
sub end_i {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
$currentstring .= '}';
@@ -944,7 +1029,7 @@ sub end_i {
sub start_address {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
$currentstring .= '\textit{';
@@ -955,7 +1040,7 @@ sub start_address {
sub end_address {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
$currentstring .= '}';
@@ -967,7 +1052,7 @@ sub end_address {
sub start_dfn {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
$currentstring .= '\textit{';
@@ -978,7 +1063,7 @@ sub start_dfn {
sub end_dfn {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
$currentstring .= '}';
@@ -990,7 +1075,7 @@ sub end_dfn {
sub start_tt {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
$currentstring .= '\texttt{';
@@ -1001,7 +1086,7 @@ sub start_tt {
sub end_tt {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
$currentstring .= '}';
@@ -1013,7 +1098,7 @@ sub end_tt {
sub start_kbd {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
$currentstring .= '\texttt{';
@@ -1024,7 +1109,7 @@ sub start_kbd {
sub end_kbd {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
$currentstring .= '}';
@@ -1036,7 +1121,7 @@ sub end_kbd {
sub start_code {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
$currentstring .= '\texttt{';
@@ -1047,7 +1132,7 @@ sub start_code {
sub end_code {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
$currentstring .= '}';
@@ -1059,7 +1144,7 @@ sub end_code {
sub start_em {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
$currentstring .= '\emph{';
@@ -1070,7 +1155,7 @@ sub start_em {
sub end_em {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
$currentstring .= '}';
@@ -1082,7 +1167,7 @@ sub end_em {
sub start_q {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
$currentstring .= '\emph{';
@@ -1093,7 +1178,7 @@ sub start_q {
sub end_q {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
$currentstring .= '}';
@@ -1101,62 +1186,115 @@ sub end_q {
return $currentstring;
}
+#
is a bit strange since it does not require a closing
+# However in latex, we must often output closing stuff to end
+# environments and {}'s etc. Therefore we do all the work
+# of figuring out the ending strings in the start tag processing,
+# and provide a mechanism to output the stop text external
+# to tag processing.
+#
+{
+
+ my $closing_string = ''; # String required to close
+
+# Some tags are
fragile meaning that
inside of them
+# does not work within TeX mode. This is managed via the
+# counter below:
+#
+
+ my $para_disabled = 0;
+
+sub disable_para {
+ $para_disabled++;
+}
+sub enable_para {
+ $para_disabled--;
+}
+
+
#--
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') {
+ if ($target eq 'web' || $target eq 'webgrade') {
+ $currentstring .= &end_p(); # close off prior para if in progress.
$currentstring .= $token->[4];
- } elsif ($target eq 'tex') {
+ if (! ($currentstring =~ /\//)) {
+ $closing_string = '
'; # Deal correctly with e.g.
+ }
+ } elsif ($target eq 'tex' && !$para_disabled) {
+
+ $currentstring .= &end_p(); # close off prior para if in progress.
my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
if ($align eq 'center') {
- $currentstring='\begin{center}\par';
+ $currentstring .='\begin{center}\par ';
+ $closing_string = '\end{center}';
+ if (&is_inside_of($tagstack, "table")) {
+ $currentstring = ¢er_correction().$currentstring;
+ }
} elsif ($align eq 'right') {
- $currentstring='\makebox['.$ENV{'form.textwidth'}.']{\hfill\llap{';
+ $currentstring.="\n".'{\flushright ';
+# $currentstring.='\makebox['.$env{'form.textwidth'}.']{\hfill\llap{';
+ $closing_string= "}\n";
} elsif ($align eq 'left') {
- $currentstring='\noindent\makebox['.$ENV{'form.textwidth'}.']{\rlap{';
+ $currentstring.= "\n".'{\flushleft ';
+# $currentstring.='\noindent\makebox['.$env{'form.textwidth'}.']{{';
+ $closing_string = "}\n";
} else {
- $currentstring='\par ';
+ $currentstring.='\par ';
+ if (&is_inside_of($tagstack, 'table')) {
+ $closing_string = '\vskip 0pt'; # Seems to be consistent with
in tables.
+ } else {
+ $closing_string = '\strut\\\\\strut ';
+ }
}
- my $signal=1;#
does not work inside ...
- foreach my $tag (@$tagstack) {if (lc($tag) eq 'b') {$signal=0;}
- if (!$signal) {$currentstring = '';}
- }
+
}
return $currentstring;
}
-
+#
+# End paragraph processing just requires that we output the
+# closing string that was saved and blank it.
sub end_p {
- 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}';
- }
- }
+ # Note only 'tex' mode uses disable_para and enable_para
+ # so we don't need to know the target in the check below:
+
+ if (!$para_disabled) {
+ my $current_string = $closing_string;
+ $closing_string = ''; # Not in a para anymore.
+ return $current_string;
+ } else {
+ return '';
}
- return $currentstring;
-}
+}
+}
#-- tag (end tag forbidden)
sub start_br {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
- if ($$tagstack[-2] ne 'sub' && $$tagstack[-2] ne 'sup') {
- $currentstring .= '\vskip 0.2 mm ';
+ 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')) {
+ $signal=1;
+ }
+ if (($tempo[$i] eq 'td') || ($tempo[$i] eq 'th')) {
+ $signal = 1;
+ }
}
+ if ($signal != 1) {
+ $currentstring .= '\strut \\\\ \strut ';
+ }
+
}
return $currentstring;
}
@@ -1164,7 +1302,7 @@ sub start_br {
sub end_br {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
}
return $currentstring;
@@ -1174,7 +1312,7 @@ sub end_br {
sub start_big {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
$currentstring .= '{\large ';
@@ -1185,7 +1323,7 @@ sub start_big {
sub end_big {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
$currentstring .= '}';
@@ -1197,7 +1335,7 @@ sub end_big {
sub start_small {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
$currentstring .= '{\footnotesize ';
@@ -1208,7 +1346,7 @@ sub start_small {
sub end_small {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
$currentstring .= '}';
@@ -1220,7 +1358,7 @@ sub end_small {
sub start_basefont {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
my $basesize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
@@ -1234,7 +1372,7 @@ sub start_basefont {
sub end_basefont {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
my $basesize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
@@ -1249,12 +1387,8 @@ sub end_basefont {
sub start_font {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
- if ($face!~/symbol/i) {
- if (($ENV{'browser.fontenhance'} eq 'on') ||
- ($ENV{'browser.blackwhite'} eq 'on')) { return ''; }
- }
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
@@ -1268,7 +1402,7 @@ sub start_font {
sub end_font {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
@@ -1283,7 +1417,7 @@ sub end_font {
sub start_strike {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
&Apache::lonxml::startredirection();
@@ -1294,7 +1428,7 @@ sub start_strike {
sub end_strike {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
$currentstring=&Apache::lonxml::endredirection();
@@ -1309,7 +1443,7 @@ sub end_strike {
sub start_s {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
&Apache::lonxml::startredirection();
@@ -1320,7 +1454,7 @@ sub start_s {
sub end_s {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
$currentstring=&Apache::lonxml::endredirection();
@@ -1335,10 +1469,10 @@ sub end_s {
sub start_sub {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
- $currentstring .= '\ensuremath{_{';
+ $currentstring .= '\raisebox{-\smallskipamount}{\scriptsize{';
}
return $currentstring;
}
@@ -1346,7 +1480,7 @@ sub start_sub {
sub end_sub {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
$currentstring .= '}}';
@@ -1358,10 +1492,10 @@ sub end_sub {
sub start_sup {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
- $currentstring .= '\ensuremath{^{';
+ $currentstring .= '\raisebox{\smallskipamount}{\scriptsize{';
}
return $currentstring;
}
@@ -1369,7 +1503,7 @@ sub start_sup {
sub end_sup {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
} elsif ($target eq 'tex') {
$currentstring .= '}}';
@@ -1380,10 +1514,31 @@ sub end_sup {
#--
tag (end tag forbidden)
sub start_hr {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
- my $currentstring = '';
- if ($target eq 'web') {
+ my $currentstring = &end_p(); # End enclosing para.
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
} elsif ($target eq 'tex') {
+
+ # can't be inside of thank you LaTeX.
+ #
+ my $restart_sub = 0;
+ my $restart_sup = 0;
+
+ # Since and are simple tags it's ok to turn off/on
+ # using the start_ stop_ functions.. those tags only care about
+ # $target.
+
+ if (&is_inside_of($tagstack, "sub")) {
+ $restart_sub = 1;
+ $currentstring .= &end_sub($target, $token, $tagstack,
+ $parstack, $parser, $safeeval);
+ }
+ if (&is_inside_of($tagstack, "sup")) {
+ $restart_sup = 1;
+ $currentstring .= &end_sup($target, $token, $tagstack,
+ $parstack, $parser, $safeeval);
+ }
+
my $LaTeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
if (defined $LaTeXwidth) {
if ($LaTeXwidth=~/^%/) {
@@ -1404,6 +1559,16 @@ sub start_hr {
}
$currentstring .= ' \vskip 0 mm \noindent\makebox['.$LaTeXwidth.']{'.$pre.'\makebox['.
$LaTeXwidth.'][b]{\hrulefill}'.$post.'}\vskip 0 mm ';
+ # Turn stuff back on that we can't be inside of.
+
+ if ($restart_sub) {
+ $currentstring .= &start_sub($target, $token, $tagstack,
+ $parstack, $parser, $safeeval);
+ }
+ if ($restart_sup) {
+ $currentstring .= &start_sup($target, $token, $tagstack,
+ $parstack, $parser, $safeeval);
+ }
}
return $currentstring;
}
@@ -1411,48 +1576,103 @@ sub start_hr {
sub end_hr {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[2];
}
return $currentstring;
}
#--