Preserve unlocatable extracts as instance excerpts in nuVal and nuVnu (fixes #38) - #79
Open
wittjeff wants to merge 1 commit into
Open
Preserve unlocatable extracts as instance excerpts in nuVal and nuVnu (fixes #38)#79wittjeff wants to merge 1 commit into
wittjeff wants to merge 1 commit into
Conversation
…fixes jrpool#38) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #38.
Problem
nuValandnuVnuuse a message'sextractonly to obtain adata-xpathattribute for the element catalog, then discard it. For messages whose extract is not annotated HTML — notablyCSS: Parse Error., whose extract is the erroneous CSS itself —getAttributeXPathfalls back to/html, so the standard instance is anchored to the page root and the only informative content of the violation is lost. A report consumer seesCSS: Parse Error.with no indication of what failed to parse or where.Fix
A new shared helper,
getExtractExcerptinprocs/nu.js, returns the extract as anexcerptfor the standard instance only when the extract contains nodata-xpathattribute — exactly the complement of the case the catalog already handles. So:{ruleID, what, ordinalSeverity, count, catalogIndex}shape, with element details normalized in the catalog.excerpt, truncated at 400 characters (CSS extracts can be whole minified stylesheets).Both
tests/nuVal.jsandtests/nuVnu.jsuse the helper, keeping the two engines' standardization identical.Verification
node --checkpasses on all three files.data-xpath-annotated extract returns null; missing/empty extract returns null without throwing (e.g. the Nu checker'sToo many messages.fatal, which has no extract); >400-char extract truncated with an ellipsis.nuValreporter with a stubbed validator response containing oneCSS: Parse Error.and one ordinary HTML message:[ { "ruleID": "CSS: Parse Error.", "what": "CSS: Parse Error.", "ordinalSeverity": 3, "count": 1, "catalogIndex": "0", "excerpt": ".hero { colr: #fff, }" }, { "ruleID": "Bad value for attribute role on element div.", "what": "Bad value for attribute role on element div.", "ordinalSeverity": 3, "count": 1, "catalogIndex": "1" } ]If you would rather surface the extract on all nuVal/nuVnu instances (not only unlocatable ones), I'm happy to adjust — this version keeps report size flat for the common DOM case.
🤖 Generated with Claude Code