Skip to content

Conversation

@ychenlian
Copy link
Contributor

Hello,

I recently found an issue where es-html-parser was returning errors when the HTML file contains patterns like

<div
    class=""
    id=""
>test</div
>

with an error like this:

Parsing error: Unable to parse close tag name.
</div
    > does not match pattern of closing tag.

I initially thought the parser just doesn't accept newlines in closing tag. Then I found that the same file parses without errors in a Linux environment, which is when I realized it was actually a line ending issue.

Here's a pull request to fix it. Please let me know if you require any changes.

Thanks. 🙂

@yeonjuan yeonjuan requested a review from Copilot October 10, 2025 11:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request fixes an issue where the HTML parser failed to handle CRLF line endings in closing tags, causing parsing errors on Windows systems. The parser was previously only handling LF (Unix) line endings but not CRLF (Windows) line endings when parsing close tag names.

  • Updated the close tag name regex pattern to handle both LF and CRLF line endings
  • Added comprehensive test coverage for both LF and CRLF scenarios in closing tags

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/constants/regex.ts Updated CLOSE_TAG_NAME_PATTERN regex to accept CRLF line endings
src/utils/tests/parse-close-tag-name.spec.ts Added test cases for LF and CRLF line endings in close tags

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Owner

@yeonjuan yeonjuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ychenlian Thanks for fixing it. LGTM!

@ychenlian
Copy link
Contributor Author

No problem. 👍

@yeonjuan yeonjuan merged commit 69d8fde into yeonjuan:main Oct 13, 2025
1 check passed
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.

2 participants