Skip to content

Commit

Permalink
Backport pull request #2214
Browse files Browse the repository at this point in the history
wiktionary: allow for multi-line etymologies
  • Loading branch information
dgw committed Dec 11, 2021
1 parent 3fc0a40 commit 57ea7fa
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions sopel/modules/wiktionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def text(html):
text = text.replace('(intransitive', '(intr.')
text = text.replace('(transitive', '(trans.')
text = web.decode(text)
return text
return text.strip()


def wikt(word):
Expand All @@ -74,9 +74,13 @@ def wikt(word):

if not is_new_mode:
if (mode == 'etymology') and ('<p>' in line):
etymology = text(line)
if etymology is not None:
# multi-line etymologies do exist (e.g. see "mayhem")
etymology += ' ' + text(line)
else:
etymology = text(line)
# 'id="' can occur in definition lines <li> when <sup> tag is used for references;
# make sure those are not excluded (see e.g., abecedarian).
# make sure those are not excluded (e.g. see "abecedarian").
elif ('id="' in line) and ('<li>' not in line):
mode = None
elif (mode is not None) and ('<li>' in line):
Expand Down

0 comments on commit 57ea7fa

Please sign in to comment.