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

HTML parsing options #45

Open
TheJaredWilcurt opened this issue Dec 21, 2020 · 1 comment
Open

HTML parsing options #45

TheJaredWilcurt opened this issue Dec 21, 2020 · 1 comment
Labels
enhancement New feature or request needs discussion

Comments

@TheJaredWilcurt
Copy link
Member

TheJaredWilcurt commented Dec 21, 2020

There are several parsing options in parse5 that we may want to pass along to the user. For example a simple switch for document parsing or fragment parsing.

With document parsing this

<div>Hi</div>

becomes

<!DOCTYPE ><html><head></head><body><div>Hi</div></body></html>

With fragment parsing

<!DOCTYPE><html><head></head><body><div>Hi</div></body></html>

becomes

<div>Hi</div>

We could try some clever analysis of the input, but it would be better to just pass this level of control to the user.

Probably something like this.

{
  tasks: [
    {
      markup: [
        {
          in: './partials/footer.html',
          out: './dist/partials/footer.html',
          fragment: true
        }
      ]
    }
  ]
}

My only concern is that right now we are barely using Parse5. Just to produce the HTML AST, and the to serialize it back to a string. So if we wanted to switch to a different library for added features, it would be mostly unnoticeable to users. The more features we adopt the harder it would be to change HTML parser down the road.

@TheJaredWilcurt
Copy link
Member Author

Relates to #44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs discussion
Projects
Status: Backlog
Development

No branches or pull requests

1 participant