Skip to content

Fix Chinese Search Bug #245

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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: 5 additions & 0 deletions questionnaires/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ def write_to_markdown(universities: dict, filename_map: FilenameMap, archived: b
if archived:
name += ' (已归档)'
folder_name = join_path('dist', 'docs')

# Ignored samples with excessively long names
if len(filename) > 150:
continue

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for the modification is that an error was encountered while writing files on account of long filename. This is not relevant to the main work of this PR.

with open(join_path(folder_name, filename), 'w', encoding='utf-8') as f:
# write header
f.write(f'# {name}\n\n')
Expand Down
8 changes: 6 additions & 2 deletions questionnaires/mkdocs_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ theme:
code: Roboto Mono
features:
- instant
custom_dir: overrides

extra:
social:
Expand All @@ -59,7 +60,10 @@ markdown_extensions:

plugins:
- search:
lang: ja
indexing: titles
lang:
- ja
- en
indexing: 'titles'
min_search_length: 2
separator: '[\s\-\.]+'
- awesome-pages
15 changes: 15 additions & 0 deletions questionnaires/site/overrides/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends "base.html" %}

{% block config %}
<script>
var search = {
transform: function(query) {
query = query + ' astopwordflagbylorenzo'; // Trigger stop-word mechanism
return query
.replace(/(?:^|\s+)[*+-:^~]+(?=\s+|$)/g, "")
.trim()
.replace(/\s+|\b$/g, "* ")
}
}
</script>
{% endblock %}