Handle incoming line breaks
This commit is contained in:
parent
6d646e082b
commit
c89c59e7fc
@ -269,12 +269,11 @@ class Portal(DBPortal, BasePortal):
|
|||||||
chunks.append({"type": "data", "data": data})
|
chunks.append({"type": "data", "data": data})
|
||||||
|
|
||||||
def handle_starttag(tag, attrs):
|
def handle_starttag(tag, attrs):
|
||||||
if tag == "img":
|
obj = {"type": tag}
|
||||||
obj = {"type": tag}
|
for attr in attrs:
|
||||||
for attr in attrs:
|
obj[attr[0]] = attr[1]
|
||||||
obj[attr[0]] = attr[1]
|
nonlocal chunks
|
||||||
nonlocal chunks
|
chunks.append(obj)
|
||||||
chunks.append(obj)
|
|
||||||
|
|
||||||
parser = HTMLParser()
|
parser = HTMLParser()
|
||||||
parser.handle_data = handle_data
|
parser.handle_data = handle_data
|
||||||
@ -286,7 +285,12 @@ class Portal(DBPortal, BasePortal):
|
|||||||
|
|
||||||
for chunk in chunks:
|
for chunk in chunks:
|
||||||
ctype = chunk["type"]
|
ctype = chunk["type"]
|
||||||
if ctype == "data":
|
if ctype == "br":
|
||||||
|
msg_text += "\n"
|
||||||
|
if not msg_html:
|
||||||
|
msg_html = msg_text
|
||||||
|
msg_html += "<br>"
|
||||||
|
elif ctype == "data":
|
||||||
msg_text += chunk["data"]
|
msg_text += chunk["data"]
|
||||||
if msg_html:
|
if msg_html:
|
||||||
msg_html += chunk["data"]
|
msg_html += chunk["data"]
|
||||||
|
Loading…
Reference in New Issue
Block a user