Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wiktionary: allow for multi-line etymologies #2214

Merged
merged 1 commit into from
Dec 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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