mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
完善format_html()
This commit is contained in:
parent
11e36d5b0c
commit
dfc557b2df
@ -5,7 +5,7 @@
|
|||||||
@File : common.py
|
@File : common.py
|
||||||
"""
|
"""
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
# from html import unescape
|
from html import unescape
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from re import split as re_SPLIT
|
from re import split as re_SPLIT
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
@ -217,20 +217,15 @@ def _make_search_str(search_str: str) -> str:
|
|||||||
return search_str
|
return search_str
|
||||||
|
|
||||||
|
|
||||||
def format_html(text: str, replace_space: bool = True) -> str:
|
def format_html(text: str, trans: bool = True) -> str:
|
||||||
"""处理html编码字符"""
|
"""处理html编码字符"""
|
||||||
if not text:
|
if not text:
|
||||||
return text
|
return text
|
||||||
|
|
||||||
# text = unescape(text)
|
if trans:
|
||||||
|
text = unescape(text)
|
||||||
|
|
||||||
# if '&' in text:
|
return text.replace('\xa0', ' ')
|
||||||
# html = unescape(text)
|
|
||||||
|
|
||||||
if replace_space:
|
|
||||||
text = text.replace('\xa0', ' ')
|
|
||||||
|
|
||||||
return text
|
|
||||||
|
|
||||||
|
|
||||||
def translate_loc(loc: tuple) -> tuple:
|
def translate_loc(loc: tuple) -> tuple:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user