Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p:first-of-type and p:last-of-type CSS selectors not working as expected with Nokogiri #908

Closed
aruprakshit opened this issue Jun 1, 2013 · 3 comments

Comments

@aruprakshit
Copy link

I tried the below code:

require "nokogiri"
doc =  Nokogiri::HTML::Document.parse(<<-eohtml)
<html>
  <head>
    <style>
    span.fot { color: red; font-size: 120%; font-style: italic; }
    </style>
  </head>
<body>
  <div>
    <span>Corey,</span>
    <span>Yehuda,</span>
    <span>Adam,</span>
    <span>Todd</span>
  </div>
  <div>
    <b>Nobody,</b>
    <span>Jörn,</span>
    <span>Scott,</span>
    <span>Timo</span>
  </div>
</body>
</html>
eohtml

p doc.css("span:first-of-type").map(&:text)
p doc.css("span:last-of-type").map(&:text)
# >> ["Corey,"]  I expect here ["Corey,","Jörn,"]
# >> ["Timo"] I expect here ["Timo","Todd"]

p:first-of-type -> Selects every <p> element that is the first <p> element of its parent and

p:last-of-type -> Selects every <p> element that is the only <p> element of its parent

Then why nokogiri gives such unexpected output?

@leejarvis
Copy link
Member

@aruprakshit
Copy link
Author

Could you add here a simple example to show how to use Class Nokogiri::XML::EntityReference::new method. The doc doesn't carry a single example on it. Your help on this will be must appreciated. Also to give some lines to say what this class stands for?

@flavorjones
Copy link
Member

@loveGitHub Questions are for the nokogiri-talk mailing list! Thanks for understanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants