From d2ea2c2f1fa86e7a00bf76721bd1bda85d402a34 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 30 Sep 2025 13:11:05 -0700 Subject: [PATCH] define: Run html2text as a subprocess. html2text is GPL licensed. Signed-off-by: Anders Kaseorg --- zulip_bots/zulip_bots/bots/define/define.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/zulip_bots/zulip_bots/bots/define/define.py b/zulip_bots/zulip_bots/bots/define/define.py index 2d9a4d9b..f15e95c2 100644 --- a/zulip_bots/zulip_bots/bots/define/define.py +++ b/zulip_bots/zulip_bots/bots/define/define.py @@ -1,9 +1,9 @@ # See readme.md for instructions on running this code. import logging import string +import subprocess from typing import Dict -import html2text import requests from zulip_bots.lib import AbstractBotHandler @@ -66,8 +66,11 @@ def get_bot_define_response(self, original_content: str) -> str: # Show definitions line by line. for d in definitions: example = d["example"] if d["example"] else "*No example available.*" + example_text = subprocess.check_output( + ["html2text", "--unicode-snob"], input=example, text=True + ) response += "\n" + "* (**{}**) {}\n  {}".format( - d["type"], d["definition"], html2text.html2text(example) + d["type"], d["definition"], example_text ) except Exception: