--- loncom/homework/default_homework.lcpm 2005/03/28 19:20:54 1.95
+++ 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.95 2005/03/28 19:20:54 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,13 +529,17 @@ 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')) {
@@ -546,7 +550,12 @@ sub chemparse {
}
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