scrapy / scrapy/cssselect

Support :nth-child(An+B of S)

Open
#76 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

CSS Selectors Level 4
Dominant language
Python
Stars
310
Forks
70
Avg merge
2h 9m
Merged PRs (30d)
4

Description

The current CCS 4 draft has :nth-child(An+B [of S]? ), extending :nth-child(An+B)

The :nth-child(An+B [of S]? ) pseudo-class notation represents the An+Bth element that matches the selector list S among its inclusive siblings.
The CSS Syntax Module [CSS3SYN] defines the An+B notation. If S is omitted, it defaults to *.

By passing a selector argument, we can select the Nth element that matches that selector. For example, the following selector matches the first three “important” list items, denoted by the .important class:
:nth-child(-n+3 of li.important)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CSS Selectors draft linked in the issue, then locate cssselect's selector parser and existing :nth-child handling. Check how the An+B expression and selector argument are represented, and verify that selectors such as :nth-child(-n+3 of li.important) parse and produce the expected result.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, python
Domain
frontend, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.