Skip to content

fix: remove comments using language parsers - #603

Closed
majestic-owl448 wants to merge 2 commits into
freeCodeCamp:mainfrom
majestic-owl448:fix/comment-removal
Closed

majestic-owl448 wants to merge 2 commits into
freeCodeCamp:mainfrom
majestic-owl448:fix/comment-removal

Conversation

@majestic-owl448

Copy link
Copy Markdown
Contributor

Checklist:

Use language parsers and tokenizers to locate comments in HTML, CSS, JavaScript, and Python, then remove their ranges from the original source. This preserves formatting and literal content, including cases that the existing regex helpers misidentify as comments. JavaScript comment removal preserves line breaks and inserts separators where deletion would join tokens.

Use parse5 for HTML, @csstools/css-tokenizer for CSS, @lezer/python for Python, and Acorn with JSX and loose parsing for JavaScript. Add 70 regression cases and browser integration coverage. Package registry signatures, install scripts, and known advisories were checked before adopting the dependencies.

Keep this PR in draft because the eager parser imports increase every evaluator's startup bundle. The JavaScript evaluator grows from 38,661 to 201,875 bytes gzipped, about 159 KiB extra. The compressed npm package grows from 2.23 to 2.70 MiB. The loading design needs further work before this is ready to merge.

@majestic-owl448 majestic-owl448 mentioned this pull request Sep 17, 2026
2 tasks done
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​lezer/​python@​1.1.19991007381100
Addedacorn-loose@​8.5.21001009183100
Added@​csstools/​css-tokenizer@​4.0.010010010084100

View full report

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.

1 participant