Summary
HTML class attribute values contain space-separated class names that should each be indexed as distinct symbol references, not as a single blob. Currently, <div class="btn btn-primary mx-2"> captures the entire string as one symbol, preventing fine-grained class lookups (e.g., searching for "btn" or "mx-2"). This is especially critical for Tailwind CSS and other utility-first frameworks where individual class names are the navigation unit.
Where
src/CodeIndex/Indexer/Symbols/SymbolExtractor.Markup.cs:ExtractHtmlSymbols() — Attribute value processing loop (around line 180-230) enumerates attribute names and values but treats multi-valued strings as atomic
- Tests: No coverage in
tests/CodeIndex.Tests/SymbolExtractorTests.cs for class attribute enumeration
Suggested approach
- When processing
class attribute (and similarly className in XHTML/JSX contexts), split the value on whitespace after extracting the quoted/unquoted value
- Emit one symbol record per whitespace-separated token
- Validate against edge cases: empty tokens (double spaces), special CSS characters (
:, [, ]), and Tailwind variant syntax (e.g., md:flex, hover:bg-red)
- Consider normalizing leading/trailing whitespace and collapsing internal runs
- Add test coverage for minified HTML with multi-class attributes and Tailwind-like class names
Summary
HTML
classattribute values contain space-separated class names that should each be indexed as distinct symbol references, not as a single blob. Currently,<div class="btn btn-primary mx-2">captures the entire string as one symbol, preventing fine-grained class lookups (e.g., searching for "btn" or "mx-2"). This is especially critical for Tailwind CSS and other utility-first frameworks where individual class names are the navigation unit.Where
src/CodeIndex/Indexer/Symbols/SymbolExtractor.Markup.cs:ExtractHtmlSymbols()— Attribute value processing loop (around line 180-230) enumerates attribute names and values but treats multi-valued strings as atomictests/CodeIndex.Tests/SymbolExtractorTests.csfor class attribute enumerationSuggested approach
classattribute (and similarlyclassNamein XHTML/JSX contexts), split the value on whitespace after extracting the quoted/unquoted value:,[,]), and Tailwind variant syntax (e.g.,md:flex,hover:bg-red)