MCPcopy Create free account
hub / github.com/gawel/pyquery / xpath_header_pseudo

Method xpath_header_pseudo

pyquery/cssselectpatch.py:326–340  ·  view source on GitHub ↗

Matches all header elements (h1, ..., h6):: >>> from pyquery import PyQuery >>> d = PyQuery(' title ') >>> d(':header') [ ] ..

(self, xpath)

Source from the content-addressed store, hash-verified

324 return xpath
325
326 def xpath_header_pseudo(self, xpath):
327 """Matches all header elements (h1, ..., h6)::
328
329 >>> from pyquery import PyQuery
330 >>> d = PyQuery('<div><h1>title</h1></div>')
331 >>> d(':header')
332 [<h1>]
333
334 ..
335 """
336 # this seems kind of brute-force, is there a better way?
337 xpath.add_condition((
338 "(name(.) = 'h1' or name(.) = 'h2' or name (.) = 'h3') "
339 "or (name(.) = 'h4' or name (.) = 'h5' or name(.) = 'h6')"))
340 return xpath
341
342 def xpath_parent_pseudo(self, xpath):
343 """Match all elements that contain other elements::

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected