Skip to content

Commit 57ea7fa

Browse files
committed
Backport pull request #2214
wiktionary: allow for multi-line etymologies
1 parent 3fc0a40 commit 57ea7fa

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

sopel/modules/wiktionary.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def text(html):
5050
text = text.replace('(intransitive', '(intr.')
5151
text = text.replace('(transitive', '(trans.')
5252
text = web.decode(text)
53-
return text
53+
return text.strip()
5454

5555

5656
def wikt(word):
@@ -74,9 +74,13 @@ def wikt(word):
7474

7575
if not is_new_mode:
7676
if (mode == 'etymology') and ('<p>' in line):
77-
etymology = text(line)
77+
if etymology is not None:
78+
# multi-line etymologies do exist (e.g. see "mayhem")
79+
etymology += ' ' + text(line)
80+
else:
81+
etymology = text(line)
7882
# 'id="' can occur in definition lines <li> when <sup> tag is used for references;
79-
# make sure those are not excluded (see e.g., abecedarian).
83+
# make sure those are not excluded (e.g. see "abecedarian").
8084
elif ('id="' in line) and ('<li>' not in line):
8185
mode = None
8286
elif (mode is not None) and ('<li>' in line):

0 commit comments

Comments
 (0)