case "html":
p.im = beforeHeadIM
default:
- if p.top().Namespace == "" {
- continue
- }
- p.im = inForeignContentIM
+ continue
}
return
}
// TODO: adjust foreign attributes.
p.addElement(p.tok.Data, p.tok.Attr)
p.top().Namespace = namespace
- p.im = inForeignContentIM
return true
case "caption", "col", "colgroup", "frame", "head", "tbody", "td", "tfoot", "th", "thead", "tr":
// Ignore the token.
}
// Section 12.2.5.5.
-func inForeignContentIM(p *parser) bool {
+func parseForeignContent(p *parser) bool {
switch p.tok.Type {
case TextToken:
// TODO: HTML integration points.
})
case StartTagToken:
if breakout[p.tok.Data] {
- // TODO.
+ for i := len(p.oe) - 1; i >= 0; i-- {
+ // TODO: HTML, MathML integration points.
+ if p.oe[i].Namespace == "" {
+ p.oe = p.oe[:i+1]
+ break
+ }
+ }
+ return false
}
switch p.top().Namespace {
case "mathml":
case EndTagToken:
for i := len(p.oe) - 1; i >= 0; i-- {
if p.oe[i].Namespace == "" {
- inBodyIM(p)
- break
+ return p.im(p)
}
if strings.EqualFold(p.oe[i].Data, p.tok.Data) {
p.oe = p.oe[:i]
break
}
}
- p.resetInsertionMode()
return true
default:
// Ignore the token.
return true
}
+// Section 12.2.5.
+func (p *parser) inForeignContent() bool {
+ if len(p.oe) == 0 {
+ return false
+ }
+ n := p.oe[len(p.oe)-1]
+ if n.Namespace == "" {
+ return false
+ }
+ // TODO: MathML, HTML integration points.
+ // TODO: MathML's annotation-xml combining with SVG's svg.
+ return true
+}
+
func (p *parser) parse() error {
// Iterate until EOF. Any other error will cause an early return.
consumed := true
return err
}
}
- consumed = p.im(p)
+ if p.inForeignContent() {
+ consumed = parseForeignContent(p)
+ } else {
+ consumed = p.im(p)
+ }
}
// Loop until the final token (the ErrorToken signifying EOF) is consumed.
for {