Added highlighting for CDATA sections
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
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: /(<|<)\/?[\w\W]+?(>|>)/gi,
+ pattern: /(<|<)\/?[\w:-]+\s*[\w\W]*?(>|>)/gi,
inside: {
'tag': {
pattern: /^(<|<)\/?[\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"><!DOCTYPE html>
<html></html></code></pre>
+
+ <h2>CDATA section</h2>
+ <pre class="prism"><code class="language-markup"><ns1:description><![CDATA[
+ CDATA is <not> magical.
+]]></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': /<!DOCTYPE.+?(>|>)/,
'script': null,
'style': null,
+ 'cdata': /<!\[CDATA\[[\w\W]+]]>/i,
'tag': {
- pattern: /(<|<)\/?[\w\W]+?(>|>)/gi,
+ pattern: /(<|<)\/?[\w:-]+\s*[\w\W]*?(>|>)/gi,
inside: {
'tag': {
pattern: /^(<|<)\/?[\w:-]+/i,