mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2026-05-10 18:57:56 +08:00
fix render encoding
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import asyncio
|
||||
import base64
|
||||
from html import escape
|
||||
from typing import Awaitable, Callable, Optional
|
||||
from urllib.parse import quote
|
||||
@@ -91,7 +92,8 @@ class Render(metaclass=Singleton):
|
||||
lines = text.split('\n')
|
||||
parsed_lines = list(map(lambda x: '<p>{}</p>'.format(escape(x)), lines))
|
||||
html_text = '<div style="width:17em;padding:1em">{}</div>'.format(''.join(parsed_lines))
|
||||
url = 'data:text/html,{}'.format(quote(html_text))
|
||||
url = 'data:text/html;charset=UTF-8;base64,{}'.format(base64.b64encode(html_text.encode()).decode())
|
||||
logger.info(url)
|
||||
data = await self.render(url, target='div')
|
||||
return data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user