mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-05-07 12:03:43 -05:00
Wikifetch: only show "possible results" in disambiguation pages if parsing succeeds
This commit is contained in:
parent
d1eea2a0a4
commit
9f1f04d25c
@ -177,20 +177,22 @@ class Wikifetch(callbacks.Plugin):
|
||||
tree.xpath('//table[@id="setindexbox"]') or \
|
||||
tree.xpath('//div[contains(@class, "disambig")]') # Wikia (2017-01-27)
|
||||
if disambig:
|
||||
reply += format(_('%u is a disambiguation page. '), addr)
|
||||
disambig = tree.xpath('//div[@id="bodyContent"]/div/ul/li')
|
||||
# Hackishly bold all <a> tags
|
||||
r = []
|
||||
|
||||
disambig_results = []
|
||||
for item in disambig:
|
||||
for link in item.findall('a'):
|
||||
if link.text is not None:
|
||||
# Hackishly bold all <a> tags
|
||||
link.text = "%s" % link.text
|
||||
item = item.text_content().replace('', '\x02')
|
||||
# Normalize and strip whitespace, to prevent newlines and such
|
||||
# from corrupting the display.
|
||||
item = utils.str.normalizeWhitespace(item).strip()
|
||||
r.append(item)
|
||||
reply += format(_('%u is a disambiguation page. '
|
||||
'Possible results include: %L'), addr, r)
|
||||
disambig_results.append(item)
|
||||
if disambig_results:
|
||||
reply += format(_('Possible results include: %L'), disambig_results)
|
||||
|
||||
# Catch talk pages
|
||||
elif 'ns-talk' in tree.find("body").attrib['class']:
|
||||
|
Loading…
x
Reference in New Issue
Block a user