Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/net/html: text node is moved outside <table> #37260

Open
pierrre opened this issue Feb 17, 2020 · 2 comments
Open

x/net/html: text node is moved outside <table> #37260

pierrre opened this issue Feb 17, 2020 · 2 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@pierrre
Copy link

pierrre commented Feb 17, 2020

What version of Go are you using (go version)?

Playground, Go 1.13

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

Playground

What did you do?

https://play.golang.org/p/UmY2tC6CML5

What did you expect to see?

The output HTML should be identical to the input.

What did you see instead?

The test text node is moved before <table>.

Yes, I know that it's not correct to have a text node directly inside a <table>.
However, I'm manipulating an HTML document containing templating instructions from https://github.com/flosch/pongo2 .
My goal is to do some changes in the HTML before rendering the template.

Is it possible to not move these text nodes, even if the HTML is not strictly valid ?
Is there another workaround ?

@gopherbot gopherbot added this to the Unreleased milestone Feb 17, 2020
@toothrot toothrot added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 18, 2020
@toothrot
Copy link
Contributor

/cc @nigeltao

@namusyaka
Copy link
Member

The behavior looks working as expected because our parser tries to parse the given string according to the whatwg parsing/tokenization algorithm strictly. You can also check it by using Google Chrome and you'll see the text node is moved before the table element as well.

I may not understand what the workaround, but does the following example meet your expectation?
https://play.golang.org/p/duwjtPFno0A

This will adjust the text node in the parsed tree directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants