html.js
1.5 KB
define(['parser/preprocessor', 'jquery'], function (preprocessor) {
'use strict';
function getDoctype(type) {
switch (type) {
case "HTML 4.01 Strict":
return '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
case "HTML 4.01 Transitional":
return '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
case "HTML 4.01 Frameset":
return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
case "XHTML 1.0 Transitional":
return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
case "XHTML 1.0 Frameset":
return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
case "XHTML 1.1":
return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
default:
return "<!DOCTYPE html>";
}
}
return function (opts) {
var dtd = $.Deferred();
opts.doctype = getDoctype(opts.doctype);
preprocessor(opts.preprocessor, opts.code).then(function(code) {
opts.code = code;
dtd.resolve(opts);
});
return dtd;
};
});