[LON-CAPA-cvs] cvs: loncom /homework/cleanxml xml_to_loncapa.pm
damieng
damieng at source.lon-capa.org
Tue Jan 19 19:41:32 EST 2016
damieng Wed Jan 20 00:41:32 2016 EDT
Modified files:
/loncom/homework/cleanxml xml_to_loncapa.pm
Log:
add a \n when possible after endouttext
Index: loncom/homework/cleanxml/xml_to_loncapa.pm
diff -u loncom/homework/cleanxml/xml_to_loncapa.pm:1.6 loncom/homework/cleanxml/xml_to_loncapa.pm:1.7
--- loncom/homework/cleanxml/xml_to_loncapa.pm:1.6 Fri Jan 8 20:32:42 2016
+++ loncom/homework/cleanxml/xml_to_loncapa.pm Wed Jan 20 00:41:31 2016
@@ -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 @@
} 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 + <br>
More information about the LON-CAPA-cvs
mailing list