Skip to content

Commit

Permalink
Merge pull request #2214 from sopel-irc/wiktionary-multiline-etymology
Browse files Browse the repository at this point in the history
wiktionary: allow for multi-line etymologies
  • Loading branch information
dgw authored Dec 11, 2021
2 parents 8beb56a + 7ba7900 commit c19ce62
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 @@ -49,7 +49,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 @@ -73,9 +73,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 c19ce62

Please sign in to comment.