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

Add support for ignoring < inside stop nodes #499

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nullcatalyst
Copy link

This is useful for parsing

<script>if (a < b) {}</script>

since without it, the < is treated as a new tag. This causes the parser to throw an exception when it cannot find a corresponding > to close the tag

Purpose / Goal

Ideally I'd like to use this library to parse a small subset of HTML, and one of the problems I found with it is that it unfortunately doesn't handle < in script tags particularly well.

Currently it treats < as the start of an open tag, then looks for a corresponding > to close that tag. Sometimes this is a desirable feature to have -- like when parsing <pre> tags, the contents should still be valid HTML.

It's just <script> that is the odd ball here. This is also why it cannot simply be applied to all options.stopNodes, so a new options field had to be added. I went with options.ignoreTagsInNodes though I am not attached to that name at all, if you have a better one, please change it :)

Type

Please mention the type of PR

  • [ ]Bug Fix
  • [ ]Refactoring / Technology upgrade
  • [x]New Feature

Bookmark this repository for further updates.

This is useful for parsing
```
<script>if (a < b) {}</script>
```
since without it, the < is treated as a new tag. This causes the parser
to throw an exception when it cannot find a corresponding > to close the
tag
@amitguptagwl
Copy link
Member

Let me understand your changes. I'll try to respond as soon as possible from my side.

@amitguptagwl
Copy link
Member

Probably, we can rename checkNodePathMatch to isNodeInPaths.

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 this pull request may close these issues.

None yet

2 participants