feat(css-syntax): accept an optional CSS reference resolver - #875
Open
caugner wants to merge 2 commits into
Open
feat(css-syntax): accept an optional CSS reference resolver#875caugner wants to merge 2 commits into
caugner wants to merge 2 commits into
Conversation
Contributor
|
a1e20f7 was deployed to: https://rari-pr875.review.mdn.allizom.net/ |
caugner
marked this pull request as ready for review
September 4, 2026 09:23
caugner
force-pushed
the
csssyntax-optional-ref-resolver
branch
from
September 4, 2026 09:52
b10f195 to
32127f0
Compare
LeoMcA
approved these changes
Sep 4, 2026
caugner
marked this pull request as draft
September 4, 2026 13:35
caugner
marked this pull request as ready for review
September 4, 2026 13:40
`SyntaxRenderer::render_node` built `<type>` and `<'property'>` links by
hand, hardcoding `Reference/Values/{slug}` and `Reference/Properties/{slug}`.
`css-syntax` has no access to the MDN page tree, so it cannot tell whether
those pages exist.
Add a `CssRefResolver` callback, threaded from `render_formal_syntax` to a
new `SyntaxRenderer::render_reference` helper, which the caller can use to
map a reference to the sub-path documenting it, or to `None` to render the
node unlinked. `CssRefKind` tells the resolver whether the node is a type or
a property, sparing it from having to re-derive that from the slug.
Passing `None` keeps the previous link-everything behavior, so this commit is
a no-op on its own.
Co-authored-by: Leo McArdle <leo@mca.is> Co-authored-by: Claas Augner <495429+caugner@users.noreply.github.com>
caugner
force-pushed
the
csssyntax-optional-ref-resolver
branch
from
September 4, 2026 14:05
5a887de to
2f50558
Compare
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.
Description
Add an optional
CssRefResolvercallback torender_formal_syntax, letting the caller decide where a<type>or<'property'>node links, or that it shouldn't link at all.CssRefKindtells the resolver whether the node is a type or a property.SyntaxRenderer::render_referencehelper replaces the two hand-rolledformat!link builders inrender_node.resolver: Nonekeeps the previous behavior, so this is a no-op on its own.Motivation
render_nodehardcodedReference/Values/{slug}andReference/Properties/{slug}for every node.css-syntaxhas no access to the MDN page tree, so it cannot tell whether those pages exist, and the webref grammars reference many spec-internal productions that MDN does not document. Injecting a resolver letsrari-docsupply that knowledge without inverting the crate dependency.Passing the node kind rather than just the slug means the resolver never has to re-derive the category from a URL or a naming convention.
Additional details
Split out of #874 to keep the plumbing separate from the behavior change. All 20 existing
css-syntaxtests pass with unchanged expected HTML, which is what verifies theNonepath is a no-op; two new tests cover theSome(resolver)path for both node kinds.Related issues and pull requests
Relates to #874, which uses this to fix 1857 broken formal-syntax links.