Dedicated DOM builder class for CDATA tags.
This commit is contained in:
parent
2b250bbf42
commit
e141c084f9
|
@ -6,9 +6,10 @@ require_relative 'oga/xml/lexer'
|
||||||
require_relative 'oga/xml/parser'
|
require_relative 'oga/xml/parser'
|
||||||
require_relative 'oga/xml/node'
|
require_relative 'oga/xml/node'
|
||||||
require_relative 'oga/xml/element'
|
require_relative 'oga/xml/element'
|
||||||
require_relative 'oga/xml/comment'
|
|
||||||
require_relative 'oga/xml/text'
|
|
||||||
require_relative 'oga/xml/document'
|
require_relative 'oga/xml/document'
|
||||||
|
require_relative 'oga/xml/text'
|
||||||
|
require_relative 'oga/xml/comment'
|
||||||
|
require_relative 'oga/xml/cdata'
|
||||||
require_relative 'oga/xml/builder'
|
require_relative 'oga/xml/builder'
|
||||||
|
|
||||||
require_relative 'oga/html/parser'
|
require_relative 'oga/html/parser'
|
||||||
|
|
|
@ -61,7 +61,9 @@ module Oga
|
||||||
return Text.new(:text => node.children[0])
|
return Text.new(:text => node.children[0])
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_method :on_cdata, :on_text
|
def on_cdata(node)
|
||||||
|
return Cdata.new(:text => node.children[0])
|
||||||
|
end
|
||||||
|
|
||||||
def on_attributes(node)
|
def on_attributes(node)
|
||||||
pairs = process_all(node)
|
pairs = process_all(node)
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
module Oga
|
||||||
|
module XML
|
||||||
|
##
|
||||||
|
#
|
||||||
|
#
|
||||||
|
class Cdata < Text
|
||||||
|
def to_xml
|
||||||
|
return "<![CDATA[#{text}]]>"
|
||||||
|
end
|
||||||
|
end # Cdata
|
||||||
|
end # XML
|
||||||
|
end # Oga
|
|
@ -2,9 +2,7 @@ module Oga
|
||||||
module XML
|
module XML
|
||||||
##
|
##
|
||||||
#
|
#
|
||||||
class Comment < Node
|
class Comment < Text
|
||||||
attr_accessor :text
|
|
||||||
|
|
||||||
def to_xml
|
def to_xml
|
||||||
return "<!--#{text}-->"
|
return "<!--#{text}-->"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue