--- loncom/xml/londefdef.pm 2012/03/05 14:41:15 1.415.4.6.2.1
+++ loncom/xml/londefdef.pm 2024/02/28 18:15:50 1.456.2.6.2.4
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Tags Default Definition Module
#
-# $Id: londefdef.pm,v 1.415.4.6.2.1 2012/03/05 14:41:15 raeburn Exp $
+# $Id: londefdef.pm,v 1.456.2.6.2.4 2024/02/28 18:15:50 raeburn Exp $
#
#
# Copyright Michigan State University Board of Trustees
@@ -43,7 +43,6 @@ use Apache::lonnet;
use strict;
use Apache::lonxml;
use Apache::lontable;
-use Apache::File();
use Image::Magick;
use Apache::lonmenu();
use Apache::lonmeta();
@@ -93,6 +92,26 @@ sub start_m {
my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
if ($target eq 'web' || $target eq 'analyze') {
&Apache::lonxml::debug("M is starting with:$inside:");
+ if (!($inside =~ /^\s*\$.*\$\s*$/ || $inside =~ /^\s*\\[([].*\\[)\]]\s*$/)) {
+ # Non-math LaTeX will not be rendered correctly with MathJax
+ # and it should be avoided anyway.
+ # On top of that, MathJax will render math without $, but
+ # it will fail with tth. This is worth a warning.
+ # (even though some people might just use latex for printing)
+ &Apache::lonxml::warning(&mt('Missing $ in [_1].','<m>'));
+ } elsif (($env{'browser.type'} eq 'safari') && ($env{'form.editxmltext'}) &&
+ (($env{'form.problemmode'} eq 'view') || ($env{'form.problemmode'} eq 'discard'))) {
+ my $delimiter;
+ if ($inside =~ /\$$/) {
+ $delimiter = '$';
+ } elsif ($inside =~ /\\([)\]])$/) {
+ $delimiter = $1;
+ }
+ if ($delimiter) {
+ &Apache::lonxml::warning(&mt('Insert a space between [_1] and [_2].',
+ $delimiter,'</m>'));
+ }
+ }
my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval);
if ($eval eq 'on') {
$inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
@@ -348,7 +367,7 @@ sub start_title {
$Apache::londefdef::title =
&Apache::lonxml::get_all_text('/title',$parser,$style);
} elsif ($target eq 'tex') {
- $currentstring .= '\keephidden{Title of the document: '
+ $currentstring .= '\keephidden{Title of the document: ';
}
if ($target eq 'meta') {
$currentstring='
';
@@ -384,6 +403,9 @@ sub start_meta {
} else {
$currentstring = $token->[4];
}
+ if ($env{'form.grade_imsexport'}) {
+ $currentstring = '';
+ }
} elsif ($target eq 'meta') {
unless (&Apache::lonxml::get_param
('http-equiv',$parstack,$safeeval,undef,1)) {
@@ -458,27 +480,28 @@ sub insert_meta {
#-- tag
sub start_style {
- my ($target, $token, $tagstack, $parstack, $parser, $safeeval, $style) = @_;
- my $currentstring = '';
+ my ($target, $token, $tagstack, $parstack, $parser, $safeeval, $style) = @_;
+ my $currentstring = '';
- if ($target eq 'tex') {
- Apache::lonxml::startredirection();
- } else {
- $currentstring = $token->[4];
- }
- return $currentstring;
+ if ($target eq 'tex') {
+ Apache::lonxml::startredirection();
+ } else {
+ $currentstring = $token->[4];
+ }
+
+ return $currentstring;
}
sub end_style {
- my ($target, $token, $tagstack, $parstack, $parser, $safeeval) = @_;
- my $currentstring = '';
+ my ($target, $token, $tagstack, $parstack, $parser, $safeeval) = @_;
+ my $currentstring = '';
- if ($target eq 'tex') {
- Apache::lonxml::endredirection();
- } else {
- $currentstring = $token->[2];
- }
- return $currentstring;
+ if ($target eq 'tex') {
+ Apache::lonxml::endredirection();
+ } else {
+ $currentstring = $token->[2];
+ }
+ return $currentstring;
}
# accessrule
@@ -567,9 +590,10 @@ sub start_body {
# Breadcrumbs
&Apache::lonhtmlcommon::clear_breadcrumbs();
if ($env{'request.state'} eq 'construct') {
+ my $url=&Apache::lonnet::hreflocation('',$env{'request.filename'});
&Apache::lonhtmlcommon::add_breadcrumb({
- 'text' => 'Construction Space',
- 'href' => &Apache::loncommon::authorspace(),
+ 'text' => 'Authoring Space',
+ 'href' => &Apache::loncommon::authorspace($url),
});
&Apache::lonhtmlcommon::add_breadcrumb({
'text' => 'HTML Editor',
@@ -581,26 +605,37 @@ sub start_body {
# FIXME Where are we?
}
+ my $args = {'add_entries' => $token->[2],
+ 'force_register' => 1,};
+ if ($target eq 'web') {
+ $args->{'print_suppress'} = 1;
+ if ($env{'request.use_absolute'}) {
+ $args->{'use_absolute'} = $env{'request.use_absolute'};
+ }
+ if ($env{'form.only_body'}) {
+ $args->{'only_body'} = 1;
+ }
+ }
$currentstring =
&Apache::loncommon::start_page($Apache::londefdef::title,
$Apache::londefdef::head
- .$extra_head,
- {'add_entries' => $token->[2],
-# 'no_title' => 1,
- 'force_register' => 1});
-
+ .$extra_head,$args);
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();
+ unless ($env{'form.inhibitmenu'} eq 'yes') {
+ $header.=&edit_controls();
+ }
}
if ($env{'request.state'} eq 'construct') {
- $currentstring.=&Apache::loncommon::head_subbox(
- &Apache::loncommon::CSTR_pageheader()
- .$header);
+ unless ($env{'form.inhibitmenu'} eq 'yes') {
+ $currentstring.=&Apache::loncommon::head_subbox(
+ &Apache::loncommon::CSTR_pageheader()
+ .$header);
+ }
} elsif ($env{'request.state'} eq 'edit') {
$currentstring.=&Apache::loncommon::head_subbox($header);
}
@@ -614,9 +649,9 @@ sub start_body {
sub edit_controls {
my ($nochgview) = @_;
- my $result .= '
+ my $result = &Apache::lonxml::seteditor_javascript().'