');
$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;
@@ -121,12 +147,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);
@@ -145,31 +172,11 @@ 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();
- } elsif ($target eq 'tex') {
- @Apache::londefdef::table = ();
- $currentstring .= '\documentclass[letterpaper]{article}';
- if (($ENV{'form.latex_type'}=~'batchmode') ||
- (!$ENV{'request.role.adv'})) {$currentstring .='\batchmode';}
- $currentstring .= '\newcommand{\keephidden}[1]{}'.
- '\renewcommand{\deg}{$^{\circ}$}'.
- '\usepackage{longtable}'.
- '\usepackage{textcomp}'.
- '\usepackage{makeidx}'.
- '\usepackage[dvips]{graphicx}'.
- '\usepackage{picins}'.
- '\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;
}
@@ -177,8 +184,8 @@ sub start_html {
sub end_html {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
my $currentstring = '';
- if ($target eq 'web') {
- $currentstring = &Apache::lonxml::xmlend($target,$parser);
+ if ($target eq 'web' || $target eq 'webgrade') {
+ # end_body takes care of the
}
return $currentstring;
}
@@ -187,8 +194,8 @@ sub end_html {
sub start_head {
my ($target,$token) = @_;
my $currentstring = '';
- if ($target eq 'web') {
- $currentstring = $token->[4].&Apache::lonxml::fontsettings();
+ if ($target eq 'web' || $target eq 'webgrade') {
+ &Apache::lonxml::startredirection();
}
return $currentstring;
}
@@ -196,9 +203,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;
}
@@ -207,7 +217,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;
@@ -216,7 +226,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;
@@ -226,7 +236,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;
@@ -237,7 +247,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;
@@ -247,7 +257,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++;
@@ -263,7 +273,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='}';
@@ -275,7 +285,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;
@@ -284,7 +294,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;
@@ -294,7 +304,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;
@@ -303,7 +313,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;
@@ -313,7 +323,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;
@@ -322,7 +332,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;
@@ -330,10 +340,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: '
}
@@ -347,8 +358,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 .= '}';
}
@@ -361,13 +372,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];
}
@@ -405,6 +416,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;
}
@@ -412,7 +433,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 '') {
@@ -428,34 +449,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;
}
@@ -473,132 +509,163 @@ 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;
- if ($ENV{'request.state'} ne 'construct') {
- $currentstring .= '<'.$token->[1];
- }
- foreach (keys %{$token->[2]}) {
- $currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"';
+ if (&is_inside_of($tagstack, "head")) {
+ &end_head(@_);
}
- if ($ENV{'request.state'} ne 'construct') {
- $currentstring.='>';
- }
- if ($ENV{'request.state'} ne 'published') {
- my $remote=($ENV{'environment.remote'} ne 'off');
- $currentstring=&Apache::loncommon::bodytag(undef,undef,
- $currentstring,$remote);
- $currentstring.=(<
-
-
-EDITBUTTON
- } else {
- $currentstring.=&Apache::lonmenu::menubuttons(undef,$target,1);
- }
- $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;
}
@@ -606,21 +673,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;
@@ -629,9 +699,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;
@@ -640,8 +711,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;
@@ -655,9 +726,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;
@@ -666,7 +737,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 ';
@@ -689,8 +760,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;
@@ -704,7 +775,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;
}
@@ -712,7 +783,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 ';
@@ -732,8 +803,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;
@@ -747,7 +818,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;
}
@@ -755,7 +826,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 ';
@@ -775,8 +846,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;
@@ -790,7 +861,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;
}
@@ -798,7 +869,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 ';
@@ -818,8 +889,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;
@@ -833,7 +904,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;
}
@@ -841,7 +912,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 ';
@@ -861,8 +932,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;
@@ -876,7 +947,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;
}
@@ -884,7 +955,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 ';
@@ -905,7 +976,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{';
@@ -916,7 +987,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 .= '}';
@@ -928,7 +999,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{';
@@ -939,7 +1010,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 .= '}';
@@ -951,7 +1022,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{';
@@ -962,7 +1033,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 .= '}';
@@ -974,7 +1045,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{';
@@ -985,7 +1056,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 .= '}';
@@ -997,7 +1068,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{';
@@ -1008,7 +1079,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 .= '}';
@@ -1020,7 +1091,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{';
@@ -1031,7 +1102,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 .= '}';
@@ -1043,7 +1114,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{';
@@ -1054,7 +1125,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 .= '}';
@@ -1066,7 +1137,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{';
@@ -1077,7 +1148,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 .= '}';
@@ -1089,7 +1160,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{';
@@ -1100,7 +1171,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 .= '}';
@@ -1108,74 +1179,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') {
- my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
- if (not defined $align) {
- $currentstring.='\strut\\\\\strut ';
- } elsif ($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') {
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') ||
- ($tempo[$i] eq 'td') || ($tempo[$i] eq 'th')) {
+ ($tempo[$i] eq 'ol') || ($tempo[$i] eq 'ul')) {
$signal=1;
- last;
+ }
+ if (($tempo[$i] eq 'td') || ($tempo[$i] eq 'th')) {
+ $signal = 1;
}
}
- if ($signal) {
- $currentstring .= ' \vskip 0 mm ';
- } elsif ($$tagstack[-2] ne 'sub' && $$tagstack[-2] ne 'sup') {
+ if ($signal != 1) {
$currentstring .= '\strut \\\\ \strut ';
}
+
}
return $currentstring;
}
@@ -1183,7 +1295,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;
@@ -1193,7 +1305,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 ';
@@ -1204,7 +1316,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 .= '}';
@@ -1216,7 +1328,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 ';
@@ -1227,7 +1339,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 .= '}';
@@ -1239,7 +1351,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);
@@ -1253,7 +1365,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);
@@ -1268,12 +1380,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);
@@ -1287,7 +1395,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);
@@ -1302,7 +1410,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();
@@ -1313,7 +1421,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();
@@ -1328,7 +1436,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();
@@ -1339,7 +1447,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();
@@ -1354,10 +1462,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;
}
@@ -1365,7 +1473,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 .= '}}';
@@ -1377,10 +1485,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;
}
@@ -1388,7 +1496,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 .= '}}';
@@ -1399,10 +1507,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=~/^%/) {
@@ -1423,6 +1552,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;
}
@@ -1430,50 +1569,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;
}
#--