mirror of
https://github.com/searxng/searxng.git
synced 2025-07-12 07:49:22 +02:00
[feat] startpage: support for news and images
This commit is contained in:
parent
feb15e3878
commit
0f2fc5879d
3 changed files with 143 additions and 77 deletions
|
@ -470,6 +470,21 @@ def ecma_unescape(string: str) -> str:
|
|||
return string
|
||||
|
||||
|
||||
def remove_pua_from_str(string):
|
||||
"""Removes unicode's "PRIVATE USE CHARACTER"s (PUA_) from a string.
|
||||
|
||||
_PUA: https://en.wikipedia.org/wiki/Private_Use_Areas
|
||||
"""
|
||||
pua_ranges = ((0xE000, 0xF8FF), (0xF0000, 0xFFFFD), (0x100000, 0x10FFFD))
|
||||
s = []
|
||||
for c in string:
|
||||
i = ord(c)
|
||||
if any(a <= i <= b for (a, b) in pua_ranges):
|
||||
continue
|
||||
s.append(c)
|
||||
return "".join(s)
|
||||
|
||||
|
||||
def get_string_replaces_function(replaces: Dict[str, str]) -> Callable[[str], str]:
|
||||
rep = {re.escape(k): v for k, v in replaces.items()}
|
||||
pattern = re.compile("|".join(rep.keys()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue