"DTD/xhtml1-strict.dtd">
def initialize
@stack = [ Null ]
end
def push(element)
@stack.unshift element
end
def pop
@stack.shift
end
def top
@stack.first
end
def result
raise "can't happen @stack.size=#{@stack.size}" unless @stack.size == 1
top
end
def tag_start(name, attrs)
a = attrs.collect do |key, val|
Attr.new(key, convert(val))
end
push e(name, *a)
push Null
end
def tag_end(name)
body = pop
element = pop
element.init_body { body }
push(pop + element)
end
def text(text)
push(pop + TextElement.new(convert(text)))
end
text += ] encoding="#{encoding}"] if encoding
s = SpecialElement.new('?', text)
push(pop + s)
end
doctype(name, pub_sys, long_name, uri)
|
def doctype(name, pub_sys, long_name, uri)
s = SpecialElement.new('!',
]DOCTYPE #{name} #{pub_sys} #{long_name} #{uri}])
push(pop + s)
end
|