--- loncom/homework/default_homework.lcpm 2005/02/18 22:52:50 1.94
+++ loncom/homework/default_homework.lcpm 2005/03/29 17:57:51 1.96
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# used by lonxml::xmlparse() as input variable $safeinit to Apache::run::run()
#
-# $Id: default_homework.lcpm,v 1.94 2005/02/18 22:52:50 albertel Exp $
+# $Id: default_homework.lcpm,v 1.96 2005/03/29 17:57:51 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -529,24 +529,33 @@ sub format {
sub chemparse {
my ($reaction) = @_;
- my @tokens = split(/(\s\+|\->|<=>)/,$reaction);
+ my @tokens = split(/(\s\+|\->|<=>|<\-|\.)/,$reaction);
my $formula = '';
foreach my $token (@tokens) {
if ($token eq '->' ) {
$formula .= '\ensuremath{\rightarrow} ';
next;
}
+ if ($token eq '<-' ) {
+ $formula .= '\ensuremath{\leftarrow} ';
+ next;
+ }
if ($token eq '<=>') {
if ($external::target eq 'web' &&
&EXT('request.browser.unicode')) {
$formula .= '⇌ ';
} else {
$formula .= &web('<=> ','\ensuremath{\rightleftharpoons} ',
- '<=$gt; ');
+ '<=> ');
}
next;
}
- $token =~ /^\s*(\d*(?:&frac\d\d)?)(.*)/;
+ if ($token eq '.') {
+ $formula =~ s/(\ \;| )$//;
+ $formula .= '·';
+ next;
+ }
+ $token =~ /^\s*([\d|\/]*(?:&frac\d\d)?)(.*)/;
$formula .= $1 if ($1 ne '1'); # stoichiometric coefficient
my $molecule = $2;
@@ -558,6 +567,7 @@ sub chemparse {
$molecule =~ s/\s*//g;
# forced space
$molecule =~ s/_/ /g;
+ $molecule =~ s/-/−/g;
$formula .= $molecule.' ';
}
# get rid of trailing space