by algorithmicimperative:

1. Use `html.ParseFragment` to parse a fragment of HTML where the root elements are
`<tbody>`, `<tr>` or `<td>` (and probably other table sub-elements)

For example:

s := `<td>first</td>
    <td>second</td>
    <td>third</td>
`
doc, err := html.ParseFragment(strings.NewReader(s), &html.Node{
    Type: html.ElementNode,
    Data: "body",
    DataAtom: atom.Body,
})


2. Check the result `fmt.Printf("%#v\n", doc)`


What is the expected output?

`[]*html.Node` of 3 `td` elements


What do you see instead?

`[]*html.Node` of a single text node containing the `first second third` text.


Which operating system are you using? Linux


Which version are you using?  1.2



ParseFragment works fine with other semantically incorrect structures, like
`<option>` elements. Has trouble with table sub-elements though.

If this isn't a bug and is failing by design, perhaps we need something like
`atom.DocumentFragment` that will receive any arbitrary HTML.

Comment From: rsc

Comment 1:

Labels changed: added repo-net.

Status changed to Accepted.

Comment From: andybalholm

Comment 2:

It is working as intended, since it parses it just as it would if the fragment were
enclosed between <body> and </body>. But it does surprise people. 
A ParseFragment-like function that does not take a context, and tries to return the
parse tree that a user is likely to expect, would be nice. It would probably require
adding a new insertion mode to the parser, though, so it wouldn't be trivial.