From 57ea7fa3c3ed792c785d7439c5a9033e253ea9a0 Mon Sep 17 00:00:00 2001 From: dgw Date: Fri, 10 Dec 2021 19:09:17 -0600 Subject: [PATCH] Backport pull request #2214 wiktionary: allow for multi-line etymologies --- sopel/modules/wiktionary.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sopel/modules/wiktionary.py b/sopel/modules/wiktionary.py index 53b3dc2d50..62b51fe032 100644 --- a/sopel/modules/wiktionary.py +++ b/sopel/modules/wiktionary.py @@ -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): @@ -74,9 +74,13 @@ def wikt(word): if not is_new_mode: if (mode == 'etymology') and ('

' 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

  • when 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 ('
  • ' not in line): mode = None elif (mode is not None) and ('
  • ' in line):