Warn for invalid CSS at-rules#2747
Open
moreaki wants to merge 1 commit into
Open
Conversation
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 #2215.
Context
#2215 reports that invalid at-rules are accepted too loosely. The original example uses
@page { @footnote::before { ... } }: because::beforeis a pseudo-element and@footnoteis a page-area at-rule, the rule should be rejected with a warning instead of being treated as a valid@footnoterule.A later issue comment listed more malformed examples that were silently ignored or accepted, including
@import::before, page-area rules with invalid preludes, and unknown nested@pagerules. Some cases were already handled by f992fd5, but these examples still needed targeted checks.Changes
@pagearea rules, including margin boxes and@footnote.@importrules such as@import::before "test.css"without adding duplicate warnings for URL-resolution failures that are already reported elsewhere.@pageat-rules such as@unknown.@pagearea rules with invalid preludes, including@top-left-corner superand@footnote::before.@page { @footnote { ... } }and@page { @top-left { ... } }warning-free.Scope
This is a targeted follow-up to the previous warning work. It covers the concrete cases reported in #2215 and its comments, but it is not intended as a full audit of every malformed CSS at-rule in every possible context.
Tests
venv/bin/python -m pytest tests/css/test_errors.py::test_warnings tests/css/test_pages.pyvenv/bin/python -m pytest tests/cssvenv/bin/python -m ruff check weasyprint/css/__init__.py tests/css/test_errors.pygit diff --check