diff --git a/src/parser.js b/src/parser.js
index b5b0034..d993eff 100644
--- a/src/parser.js
+++ b/src/parser.js
@@ -58,6 +58,17 @@ function parseOpenElement(context) {
var name = context.readRegex(nameRegex);
context.callbacks.openElement(name);
readAttributes(context, false);
+
+ if (name !== 'script' && name !== 'xmp') {
+ return;
+ }
+
+ //just read until the closing tags for elements that allow cdata
+ var regex = new RegExp('^([\\s\\S]*?)(?:$|' + name + '>)', 'i');
+ var match = regex.exec(context.substring);
+ context.read(match[0].length);
+ context.callbacks.cdata(match[1]);
+ context.callbacks.closeElement(name);
}
function parseEndElement(context) {
diff --git a/tests/cdata-tests.js b/tests/cdata-tests.js
index 92b3d63..52b8638 100644
--- a/tests/cdata-tests.js
+++ b/tests/cdata-tests.js
@@ -85,4 +85,53 @@ describe('CDATA', function() {
cdataCount.should.equal(1);
textCount.should.equal(1);
});
+
+ it('script tags do not require CDATA', function() {
+ var closeCount = 0, cdataCount = 0, openCount = 0;
+ helpers.parseString('', {
+ openElement: function(name) {
+ name.should.equal('script');
+ openCount++;
+ },
+
+ closeElement: function(name) {
+ name.should.equal('script');
+ closeCount++;
+ },
+
+ cdata: function(value) {
+ value.should.equal('');
+ cdataCount++;
+ }
+ });
+
+ cdataCount.should.equal(1);
+ closeCount.should.equal(1);
+ openCount.should.equal(1);
+ });
+
+ it('xmp tags do not require CDATA', function() {
+ var closeCount = 0, cdataCount = 0, openCount = 0;
+ helpers.parseString('', {
+ openElement: function(name) {
+ name.should.equal('xmp');
+ openCount++;
+ },
+
+ closeElement: function(name) {
+ name.should.equal('xmp');
+ closeCount++;
+ },
+
+ cdata: function(value) {
+ value.should.equal('');
+ cdataCount++;
+ }
+ });
+
+ cdataCount.should.equal(1);
+ closeCount.should.equal(1);
+ openCount.should.equal(1);
+ });
+
});
\ No newline at end of file
diff --git a/tests/files/good-expected.html b/tests/files/good-expected.html
index 89a4e55..8aafe89 100644
--- a/tests/files/good-expected.html
+++ b/tests/files/good-expected.html
@@ -3,7 +3,7 @@
tommy montgomery
-
+
@@ -19,6 +19,14 @@
-
+
+
+
+