mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2025-02-26 14:11:59 +01:00
Replaced regex with backrefs package in search plugin (#8034)
Use Re in all places in the search plugin except where Unicode properties are desired (checking for Chinese chars). Use Backrefs' `bre` to check for Unicode properties. To minimize any differences, explicitly use `script` as Backrefs uses `script_extensions` (or `scx`) by default with `Is*` properties.
This commit is contained in:
parent
37162a57cd
commit
ab1511074c
@ -21,7 +21,8 @@
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import regex as re
|
||||
import re
|
||||
from backrefs import bre
|
||||
|
||||
from html import escape
|
||||
from html.parser import HTMLParser
|
||||
@ -285,7 +286,7 @@ class SearchIndex:
|
||||
|
||||
# Find and segment Chinese characters in string
|
||||
def _segment_chinese(self, data):
|
||||
expr = re.compile(r"(\p{IsHan}+)", re.UNICODE)
|
||||
expr = bre.compile(r"(\p{script: Han}+)", bre.UNICODE)
|
||||
|
||||
# Replace callback
|
||||
def replace(match):
|
||||
|
@ -30,5 +30,5 @@ pymdown-extensions~=10.2
|
||||
babel~=2.10
|
||||
colorama~=0.4
|
||||
paginate~=0.5
|
||||
regex>=2022.4
|
||||
backrefs~=5.8
|
||||
requests~=2.26
|
||||
|
@ -21,7 +21,8 @@
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import regex as re
|
||||
import re
|
||||
import backrefs as bre
|
||||
|
||||
from html import escape
|
||||
from html.parser import HTMLParser
|
||||
@ -285,7 +286,7 @@ class SearchIndex:
|
||||
|
||||
# Find and segment Chinese characters in string
|
||||
def _segment_chinese(self, data):
|
||||
expr = re.compile(r"(\p{IsHan}+)", re.UNICODE)
|
||||
expr = bre.compile(r"(\p{script: Han}+)", bre.UNICODE)
|
||||
|
||||
# Replace callback
|
||||
def replace(match):
|
||||
|
Loading…
x
Reference in New Issue
Block a user