diff options
author | Gavin Kistner <gkistner@nvidia.com> | 2013-06-06 10:43:19 -0600 |
---|---|---|
committer | Gavin Kistner <gkistner@nvidia.com> | 2013-06-06 10:54:28 -0600 |
commit | d9d6dd5f4a73363ea5d353ecda142f77ed4eba5a (patch) | |
tree | 8983c64467024b62feab6d35557d249508091d58 /lib/coderay | |
parent | 32b0cf52784f99e85527522a3dd1f70c26d26a4f (diff) | |
download | coderay-d9d6dd5f4a73363ea5d353ecda142f77ed4eba5a.tar.gz |
Support CDATA blocks in HTML/XML
Diffstat (limited to 'lib/coderay')
-rw-r--r-- | lib/coderay/scanners/html.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/coderay/scanners/html.rb b/lib/coderay/scanners/html.rb index 3ba3b79..fcf249a 100644 --- a/lib/coderay/scanners/html.rb +++ b/lib/coderay/scanners/html.rb @@ -99,7 +99,17 @@ module Scanners case state when :initial - if match = scan(/<!--(?:.*?-->|.*)/m) + if match = scan(/<!\[CDATA\[/) + encoder.begin_group :string + encoder.text_token match, :delimiter + if match = scan(/.*?\]\]>/m) + encoder.text_token match[0..-4], :content + encoder.text_token ']]>', :delimiter + else + encoder.text_token scan(/.*/m), :error + end + encoder.end_group :string + elsif match = scan(/<!--(?:.*?-->|.*)/m) encoder.text_token match, :comment elsif match = scan(/<!(\w+)(?:.*?>|.*)|\]>/m) encoder.text_token match, :doctype |