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

cannot handle line return inside closing tags #65

Open
Akronae opened this issue Mar 4, 2024 · 0 comments · May be fixed by #67
Open

cannot handle line return inside closing tags #65

Akronae opened this issue Mar 4, 2024 · 0 comments · May be fixed by #67

Comments

@Akronae
Copy link

Akronae commented Mar 4, 2024

With this example:

fn main() -> () {
    let str = r#"<!DOCTYPE html>
    <html>
      <body>
        <div>div 1</div>
        <div>div 2</div
        ><div>div 3</div>
        <div>div 4</div>
      </body>
    </html>
    "#;

    let dom = tl::parse(str, Default::default()).unwrap();
    let parser = dom.parser();
    let inner_html = dom
        .children()
        .get(1)
        .unwrap()
        .get(parser)
        .unwrap()
        .inner_html(parser)
        .to_string();

    dbg!(inner_html);
}
<body>
        <div>div 1</div>
        <div>div 2</div
        ><div>div 3</div>
        <div>div 4</div>
</body>

will be wrongly changed to

 <body>
    <div>div 1</div>
    <div>
        div 2
        <div>div 3</div>
        <div>div 4</div>
    </div>
</body>
@Akronae Akronae changed the title cannot handle line return inside tags cannot handle line return inside closing tags Mar 4, 2024
tslnc04 added a commit to tslnc04/tl that referenced this issue Apr 28, 2024
Fixes y21#65 by adding a skip whitespace before and after the name of a
closing tag. Also adds a test to verify that this functions properly,
based on the example in y21#65.

Note that the [HTML spec] does not allow for whitespace between the `</`
and the tag name, although this is accepted by these changes to maintain
symmetry with the parsing of the start of a tag which started allowing
whitespace between `<` and the tag name in c532c72.

[HTML spec]: https://html.spec.whatwg.org/multipage/syntax.html#end-tags
tslnc04 added a commit to tslnc04/tl that referenced this issue Apr 28, 2024
Fixes y21#65 by adding a skip whitespace before and after the name of a
closing tag. Also adds a test to verify that this functions properly,
based on the example in y21#65.

Note that the [HTML spec] does not allow for whitespace between the `</`
and the tag name, although this is accepted by these changes to maintain
symmetry with the parsing of the start of a tag which started allowing
whitespace between `<` and the tag name in c532c72.

[HTML spec]: https://html.spec.whatwg.org/multipage/syntax.html#end-tags
@tslnc04 tslnc04 linked a pull request Apr 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant