mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
Don't puke on non-ASCII characters when shelling out to html2text.
(imported from commit a407c9fb2a090075d5e26b5db00388f4f81de1f5)
This commit is contained in:
@@ -2227,10 +2227,11 @@ def convert_html_to_markdown(html):
|
||||
except OSError:
|
||||
continue
|
||||
|
||||
markdown = p.communicate(input=html)[0].strip()
|
||||
markdown = p.communicate(input=html.encode("utf-8"))[0].strip()
|
||||
# We want images to get linked and inline previewed, but html2text will turn
|
||||
# them into links of the form ``, which is
|
||||
# ugly. Run a regex over the resulting description, turning links of the
|
||||
# form `` into
|
||||
# `[image.png](http://foo.com/image.png)`.
|
||||
return re.sub(r"!\[\]\((\S*)/(\S*)\?(\S*)\)", r"[\2](\1/\2)", markdown)
|
||||
return re.sub(r"!\[\]\((\S*)/(\S*)\?(\S*)\)",
|
||||
r"[\2](\1/\2)", markdown).decode("utf-8")
|
||||
|
||||
Reference in New Issue
Block a user