[LON-CAPA-cvs] cvs: loncom /homework/cleanxml xml_to_loncapa.pm
damieng
damieng at source.lon-capa.org
Tue Jan 5 13:51:08 EST 2016
damieng Tue Jan 5 18:51:08 2016 EDT
Modified files:
/loncom/homework/cleanxml xml_to_loncapa.pm
Log:
HTML elements that do not have an empty content model must never use a self-closing tag
Index: loncom/homework/cleanxml/xml_to_loncapa.pm
diff -u loncom/homework/cleanxml/xml_to_loncapa.pm:1.3 loncom/homework/cleanxml/xml_to_loncapa.pm:1.4
--- loncom/homework/cleanxml/xml_to_loncapa.pm:1.3 Wed Dec 23 20:33:10 2015
+++ loncom/homework/cleanxml/xml_to_loncapa.pm Tue Jan 5 18:51:08 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.3 2015/12/23 20:33:10 damieng Exp $
+# $Id: xml_to_loncapa.pm,v 1.4 2016/01/05 18:51:08 damieng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -49,6 +49,11 @@
my @inline_responses = ('stringresponse','optionresponse','numericalresponse','formularesponse','mathresponse','organicresponse','reactionresponse','customresponse','externalresponse');
+# see http://www.w3.org/TR/html-polyglot/#empty-elements
+# and http://tiffanybbrown.com/2011/03/23/html5-does-not-allow-self-closing-tags/
+# HTML elements that do not have an empty content, and must never use a self-closing tag:
+my @non_empty_html = ('title','style','script','noscript','body','section','header','footer','article','aside','nav','h1','h2','h3','h4','h5','h6','div','p','li','dt','dd','caption','td','th','span','a','em','strong','b','i','sup','sub','pre','code','kbd','samp','cite','q','tt','ins','del','var','small','big','address','blockquote','bdo','ruby','rb','rp','rt','rtc','figure','figcaption','object','applet','video','audio','canvas','label','option','textarea','fieldset','legend','button','iframe');
+
# Converts a file and return the modified contents
sub convert_file {
@@ -95,7 +100,7 @@
$s .= escape_attribute($attribute->nodeValue);
$s .= '"';
}
- if ($node->hasChildNodes() || $tag eq 'script') {
+ if ($node->hasChildNodes() || string_in_array(\@non_empty_html, $tag)) {
$s .= '>';
foreach my $child ($node->childNodes) {
$s .= node_to_string($child);
More information about the LON-CAPA-cvs
mailing list