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

Comment parsing doesn't seem to work #270

Open
ktrieu opened this issue Feb 29, 2024 · 0 comments
Open

Comment parsing doesn't seem to work #270

ktrieu opened this issue Feb 29, 2024 · 0 comments

Comments

@ktrieu
Copy link

ktrieu commented Feb 29, 2024

I'm on Node v21.5.0 and version 6.1.12 of the library. I have a pretty simple test case that I believe should work, judging from the issue about adding comment support to querySelector (#221).

index.js

import { parse } from 'node-html-parser'
import * as fs from 'fs';

const html = fs.readFileSync('./test.html').toString();

const parsed = parse(html, { comment: true });

const comments = parsed.querySelectorAll('!--');

console.log(comments);

test.html

<html>
  <body>
    <h1>TEST</h1>
    <!-- Some comment here. -->
  </body>
</html>

However, running this code prints []. I get the same result when the HTML is included inline as a raw string, so I don't think the file handling is at fault.

taoqf added a commit that referenced this issue Mar 29, 2024
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

No branches or pull requests

1 participant