--- loncom/homework/chemresponse.pm	2005/01/31 22:00:40	1.45
+++ loncom/homework/chemresponse.pm	2005/02/17 21:42:37	1.46
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # chemical equation style response
 #
-# $Id: chemresponse.pm,v 1.45 2005/01/31 22:00:40 albertel Exp $
+# $Id: chemresponse.pm,v 1.46 2005/02/17 21:42:37 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,7 +32,7 @@ use Apache::lonxml;
 use Apache::lonnet;
 
 BEGIN {
-    &Apache::lonxml::register('Apache::chemresponse',('organicresponse','organicstructure','reactionresponse'));
+    &Apache::lonxml::register('Apache::chemresponse',('organicresponse','organicstructure','reactionresponse','chem'));
 }
 
 sub chem_standard_order {
@@ -431,5 +431,28 @@ sub end_reactionresponse {
     return $result;
 }
 
+sub start_chem {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
+    my $result = '';
+    if ($target eq 'tex' || $target eq 'web') {
+	&Apache::lonxml::startredirection();
+    }    
+    return $result;
+}
+
+sub end_chem {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
+    my $result = '';
+    if ($target eq 'tex' || $target eq 'web') {
+	@Apache::scripttag::parser_env = @_;
+	if (!$Apache::lonxml::default_homework_loaded) {
+	    &Apache::lonxml::default_homework_load($safeeval);
+	}
+	my $innards=&Apache::lonxml::endredirection();
+	$result=&Apache::run::run("return &chemparse(q\0$innards\0);",$safeeval);
+    }
+    return $result;
+}
+
 1;
 __END__