Skip to content

HTML parsing options #45

@TheJaredWilcurt

Description

@TheJaredWilcurt

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions