Skip to content

Commit cea2c44

Browse files
andersktimabbott
authored andcommitted
define: Run html2text as a subprocess.
html2text is GPL licensed. Signed-off-by: Anders Kaseorg <[email protected]>
1 parent 1386594 commit cea2c44

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

zulip_bots/zulip_bots/bots/define/define.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# See readme.md for instructions on running this code.
22
import logging
33
import string
4+
import subprocess
45
from typing import Dict
56

6-
import html2text
77
import requests
88

99
from zulip_bots.lib import AbstractBotHandler
@@ -66,8 +66,11 @@ def get_bot_define_response(self, original_content: str) -> str:
6666
# Show definitions line by line.
6767
for d in definitions:
6868
example = d["example"] if d["example"] else "*No example available.*"
69+
example_text = subprocess.check_output(
70+
["html2text", "--unicode-snob"], input=example, text=True
71+
)
6972
response += "\n" + "* (**{}**) {}\n&nbsp;&nbsp;{}".format(
70-
d["type"], d["definition"], html2text.html2text(example)
73+
d["type"], d["definition"], example_text
7174
)
7275

7376
except Exception:

0 commit comments

Comments
 (0)