Skip to content

Instantly share code, notes, and snippets.

@yorickpeterse
Created October 27, 2014 21:11
Show Gist options
  • Save yorickpeterse/e34e2b77a7cbdad1ea0b to your computer and use it in GitHub Desktop.
Save yorickpeterse/e34e2b77a7cbdad1ea0b to your computer and use it in GitHub Desktop.
2.1.3p242 > Nokogiri::CSS.xpath_for(':nth-child(4n-1)')
=> ["//*[((count(preceding-sibling::*) + 1) >= 3) and ((((count(preceding-sibling::*) + 1)-3) mod 4) = 0)]"]
2.1.3p242 > Nokogiri::CSS.xpath_for(':nth-child(4n-2)')
=> ["//*[((count(preceding-sibling::*) + 1) >= 2) and ((((count(preceding-sibling::*) + 1)-2) mod 4) = 0)]"]
2.1.3p242 > Nokogiri::CSS.xpath_for(':nth-child(4n-3)')
=> ["//*[((count(preceding-sibling::*) + 1) >= 1) and ((((count(preceding-sibling::*) + 1)-1) mod 4) = 0)]"]
2.1.3p242 > Nokogiri::CSS.xpath_for(':nth-child(4n-4)')
=> ["//*[((count(preceding-sibling::*) + 1) >= 4) and ((((count(preceding-sibling::*) + 1)-4) mod 4) = 0)]"]
2.1.3p242 > Nokogiri::CSS.xpath_for(':nth-child(4n-5)')
=> ["//*[((count(preceding-sibling::*) + 1) >= 3) and ((((count(preceding-sibling::*) + 1)-3) mod 4) = 0)]"]
2.1.3p242 > Nokogiri::CSS.xpath_for(':nth-child(4n-6)')
=> ["//*[((count(preceding-sibling::*) + 1) >= 2) and ((((count(preceding-sibling::*) + 1)-2) mod 4) = 0)]"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment