Skip to content

Remove Regex from search #8034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions material/plugins/search/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -285,7 +286,7 @@ def _find_toc_by_id(self, toc, id):

# 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):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions src/plugins/search/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -285,7 +286,7 @@ def _find_toc_by_id(self, toc, id):

# 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):
Expand Down