Skip to content

Commit

Permalink
Fixed CDATA bug in new parser.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed Aug 20, 2012
1 parent cc613a8 commit d374b5e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/zafu/parsing_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,14 @@ def scan
if @text[2..3] == '--'
store space
scan_html_comment
elsif @text[2..8] == '[CDATA['
# We do not flush because space has been eaten
store space
flush '<![CDATA['
elsif @text =~ /\A\s*<([^>]+)>/m
# Doctype/xml
flush $&
end
elsif @text[0..8] == '<![CDATA['
store space
flush '<![CDATA['
elsif $1.last == ' ' && @text[0..1] == '< '
# solitary ' < '
store space
Expand Down
14 changes: 14 additions & 0 deletions test/integration/zafu_compiler/display.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ multiline_rtag:
content='text/html; charset=utf-8' /><r:title/>
tem: '!/r:title/'

cdata:
src: |
<script type='text/javascript'>
<![CDATA[
var urls = [<r:images in='site limit 2' do='each' join=', '>'<r:url mode='med' format='data'/>'</r:images>];
//]]>
</script>
res: |
<script type='text/javascript'>
<![CDATA[
var urls = ['http://test.host/oo/image40_med.jpg?390663777446', 'http://test.host/en/image30_med.jpg?390663777446'];
//]]>
</script>
multiline_tag:
src: |
<div id='extract'>
Expand Down

0 comments on commit d374b5e

Please sign in to comment.