From fe07657fe10103c2750c1c2f08804b4bc70f5644 Mon Sep 17 00:00:00 2001 From: Kevin Date: Mon, 28 Sep 2026 21:00:53 +0200 Subject: [PATCH] fix(extract): parse only Astro frontmatter and scripts in the AST pass extract_astro fed the whole .astro file to the JS grammar. The template is not JS, so every page reported a syntax error (usually at line 1-2) and symbols tree-sitter could not recover past the template were dropped. Blank everything outside the frontmatter and JS + +""", + ) + result = extract_astro(page) + assert result.get("parse_errors") is None + labels = _labels(result) + assert "rank()" in labels and "toggle()" in labels + # Masking keeps offsets, so locations still point at the original lines. + assert labels["rank()"] == "L5" + assert labels["toggle()"] == "L15" + + +def test_extract_astro_scripts_on_one_line_do_not_merge(tmp_path): + """Two script bodies on one line must not parse as a single statement.""" + page = _write( + tmp_path / "src/pages/inline.astro", + "\n", + ) + result = extract_astro(page) + assert result.get("parse_errors") is None + assert "b()" in _labels(result)