browser/navigate: _find_nextprev allow for space sep rel attribs
The _find_nextprev function of browser/navigate.py only checks to see if the rell attribute equals 'prev', 'previous', or 'next'. This patch changes this to check for a set intersection between {'prev', 'previous'} or {'next'} and the set of the space separated list of the rel attribute.
This commit is contained in:
parent
0b94f2ed8c
commit
5b7090e402
@ -70,11 +70,11 @@ def path_up(url, count):
|
|||||||
def _find_prevnext(prev, elems):
|
def _find_prevnext(prev, elems):
|
||||||
"""Find a prev/next element in the given list of elements."""
|
"""Find a prev/next element in the given list of elements."""
|
||||||
# First check for <link rel="prev(ious)|next">
|
# First check for <link rel="prev(ious)|next">
|
||||||
rel_values = ('prev', 'previous') if prev else ('next')
|
rel_values = {'prev', 'previous'} if prev else {'next'}
|
||||||
for e in elems:
|
for e in elems:
|
||||||
if e.tag_name() not in ['link', 'a'] or 'rel' not in e:
|
if e.tag_name() not in ['link', 'a'] or 'rel' not in e:
|
||||||
continue
|
continue
|
||||||
if e['rel'] in rel_values:
|
if set(e['rel'].split(' ')) & rel_values:
|
||||||
log.hints.debug("Found {!r} with rel={}".format(e, e['rel']))
|
log.hints.debug("Found {!r} with rel={}".format(e, e['rel']))
|
||||||
return e
|
return e
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user