Skip to content

Commit 9cfd255

Browse files
author
Gavin Kistner
committed
Support CDATA blocks in HTML/XML
1 parent 864a7b2 commit 9cfd255

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/coderay/scanners/html.rb

+11-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,17 @@ def scan_tokens encoder, options
9999
case state
100100

101101
when :initial
102-
if match = scan(/<!--(?:.*?-->|.*)/m)
102+
if match = scan(/<!\[CDATA\[/)
103+
encoder.begin_group :string
104+
encoder.text_token match, :delimiter
105+
if match = scan(/.*?\]\]>/m)
106+
encoder.text_token match[0..-4], :content
107+
encoder.text_token ']]>', :delimiter
108+
else
109+
encoder.text_token scan(/.*/m), :error
110+
end
111+
encoder.end_group :string
112+
elsif match = scan(/<!--(?:.*?-->|.*)/m)
103113
encoder.text_token match, :comment
104114
elsif match = scan(/<!(\w+)(?:.*?>|.*)|\]>/m)
105115
encoder.text_token match, :doctype

0 commit comments

Comments
 (0)