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

chore: add html parser crate #2163

Merged
merged 5 commits into from
Mar 29, 2024
Merged

chore: add html parser crate #2163

merged 5 commits into from
Mar 29, 2024

Conversation

ematipico
Copy link
Member

@ematipico ematipico commented Mar 22, 2024

Summary

This PR just adds a new biome_html_parser crate. The crate doesn't have any logic yet, just some plumbing the start the infrastructure.

I took the opportunity to do some further refactor around the lexer.

Test Plan

Currect CI should pass

@github-actions github-actions bot added A-Parser Area: parser L-JavaScript Language: JavaScript and super languages L-CSS Language: CSS labels Mar 22, 2024
Copy link

netlify bot commented Mar 22, 2024

Deploy Preview for biomejs ready!

Name Link
🔨 Latest commit 765f254
🔍 Latest deploy log https://app.netlify.com/sites/biomejs/deploys/66067b4ed0d3bf00089cfff2
😎 Deploy Preview https://deploy-preview-2163--biomejs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 95 (🔴 down 5 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 93 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 49701 49701 0
Passed 48721 48721 0
Failed 980 980 0
Panics 0 0 0
Coverage 98.03% 98.03% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 40 40 0
Passed 37 37 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.50% 92.50% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 6322 6322 0
Passed 2036 2036 0
Failed 4286 4286 0
Panics 0 0 0
Coverage 32.20% 32.20% 0.00%

ts/babel

Test result main count This PR count Difference
Total 662 662 0
Passed 593 593 0
Failed 69 69 0
Panics 0 0 0
Coverage 89.58% 89.58% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 17646 17646 0
Passed 13439 13439 0
Failed 4205 4205 0
Panics 2 2 0
Coverage 76.16% 76.16% 0.00%

Copy link

codspeed-hq bot commented Mar 22, 2024

CodSpeed Performance Report

Merging #2163 will improve performances by 6.23%

Comparing chore/html-parser (765f254) with main (5e219db)

Summary

⚡ 1 improvements
✅ 92 untouched benchmarks

Benchmarks breakdown

Benchmark main chore/html-parser Change
router.ts[uncached] 13.1 ms 12.4 ms +6.23%

Copy link
Contributor

@arendjr arendjr left a comment

Choose a reason for hiding this comment

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

👍 Just some minor comments.

///
/// ## Safety
/// Must be called at a valid UT8 char boundary
fn current_char_unchecked(&self) -> char {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function is in the generic lexer now.

}

impl<'src> HtmlLexer<'src> {
/// Make a new lexer from a str, this is safe because strs are valid utf8
Copy link
Contributor

Choose a reason for hiding this comment

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

The safety comment seems a bit out of place, since there’s nothing unsafe here.


impl<'src> HtmlLexer<'src> {
fn consume_token(&mut self, current: u8) -> HtmlSyntaxKind {
// The speed difference comes from the difference in table size, a 2kb table is easily fit into cpu cache
Copy link
Contributor

Choose a reason for hiding this comment

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

What speed difference? This comment lacks context.

use biome_parser::diagnostic::ParseDiagnostic;
use biome_rowan::{AstNode, NodeCache};

/// Parses the provided string as CSS program using the provided node cache.
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment is out of date.

@github-actions github-actions bot added the A-Tooling Area: internal tools label Mar 28, 2024
@ematipico ematipico merged commit 66a99f6 into main Mar 29, 2024
12 checks passed
@ematipico ematipico deleted the chore/html-parser branch March 29, 2024 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Parser Area: parser A-Tooling Area: internal tools L-CSS Language: CSS L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants