--- loncom/homework/cleanxml/xml_to_loncapa.pm 2016/01/08 20:32:42 1.6 +++ loncom/homework/cleanxml/xml_to_loncapa.pm 2016/01/20 00:41:31 1.7 @@ -1,7 +1,7 @@ # The LearningOnline Network # convert_file takes a well-formed XML file content and converts it to LON-CAPA syntax. # -# $Id: xml_to_loncapa.pm,v 1.6 2016/01/08 20:32:42 damieng Exp $ +# $Id: xml_to_loncapa.pm,v 1.7 2016/01/20 00:41:31 damieng Exp $ # # Copyright Michigan State University Board of Trustees # @@ -255,6 +255,21 @@ sub add_endouttext { } else { $parent->appendChild($endouttext); } + # replace spaces afterwards by a \n + indentation + my $next = $endouttext->nextSibling; + if (defined $next && $next->nodeType == XML_TEXT_NODE) { + my $v = $next->nodeValue; + if ($v =~ /^ /) { + $v =~ s/^ +//; + if ($parent->firstChild->nodeType == XML_TEXT_NODE && + $parent->firstChild->nodeValue =~ /^\n +$/) { + $v = $parent->firstChild->nodeValue.$v; + } else { + $v = "\n".$v; + } + $next->setData($v); + } + } } # Convert paragraph children when one contains an inline response into content +