Commit a97d26b2b8ab066be87211f4c4fb47c5f6077e8c

Lea Verou 2012-07-13T02:31:49

Added highlighting for CDATA sections

diff --git a/components/prism-markup.js b/components/prism-markup.js
index 891cd11..6f55fd4 100644
--- a/components/prism-markup.js
+++ b/components/prism-markup.js
@@ -4,8 +4,9 @@ Prism.languages.markup = {
 	'doctype': /<!DOCTYPE.+?(>|>)/,
 	'script': null,
 	'style': null,
+	'cdata': /<!\[CDATA\[[\w\W]+]]>/i,
 	'tag': {
-		pattern: /(&lt;|<)\/?[\w\W]+?(>|&gt;)/gi,
+		pattern: /(&lt;|<)\/?[\w:-]+\s*[\w\W]*?(>|&gt;)/gi,
 		inside: {
 			'tag': {
 				pattern: /^(&lt;|<)\/?[\w:-]+/i,
diff --git a/examples.html b/examples.html
index 47acb00..5b84572 100644
--- a/examples.html
+++ b/examples.html
@@ -56,6 +56,11 @@
 	<h2>DOCTYPE</h2>
 	<pre class="prism"><code class="language-markup">&lt;!DOCTYPE html>
 &lt;html>&lt;/html></code></pre>
+
+	<h2>CDATA section</h2>
+	<pre class="prism"><code class="language-markup">&lt;ns1:description>&lt;![CDATA[
+  CDATA is &lt;not> magical.
+]]>&lt;/ns1:description></code></pre>
 </pre>
 </section>
 
diff --git a/prism.css b/prism.css
index a5600d8..06a5e4c 100644
--- a/prism.css
+++ b/prism.css
@@ -26,7 +26,8 @@ pre.prism {
 .comment,
 .line-comment,
 .prolog,
-.doctype {
+.doctype,
+.cdata {
 	color: slategray;
 }
 
diff --git a/prism.js b/prism.js
index 045d7c3..3ffd8a8 100644
--- a/prism.js
+++ b/prism.js
@@ -223,8 +223,9 @@ Prism.languages.markup = {
 	'doctype': /&lt;!DOCTYPE.+?(>|&gt;)/,
 	'script': null,
 	'style': null,
+	'cdata': /&lt;!\[CDATA\[[\w\W]+]]&gt;/i,
 	'tag': {
-		pattern: /(&lt;|<)\/?[\w\W]+?(>|&gt;)/gi,
+		pattern: /(&lt;|<)\/?[\w:-]+\s*[\w\W]*?(>|&gt;)/gi,
 		inside: {
 			'tag': {
 				pattern: /^(&lt;|<)\/?[\w:-]+/i,