Skip to content

Commit

Permalink
Merge pull request sopel-irc#2286 from SnoopJeDi/bugfix/excessive-med…
Browse files Browse the repository at this point in the history
…iawiki-whitespace

Add workaround for excessive whitespace in MediaWiki excerpts (fixes sopel-irc#2259)
  • Loading branch information
dgw authored May 29, 2022
2 parents 984e1b9 + 05d55d1 commit 36b7c2f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sopel/modules/wikipedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ def say_snippet(bot, trigger, server, query, show_url=True):

try:
snippet = mw_snippet(server, query)
# Coalesce repeated whitespace to avoid problems with <math> on MediaWiki
# see https://github.com/sopel-irc/sopel/issues/2259
snippet = re.sub(r"\s+", " ", snippet)
except KeyError:
if show_url:
bot.reply("Error fetching snippet for \"{}\".".format(page_name))
Expand Down

0 comments on commit 36b7c2f

Please sign in to comment.