Thai tone marks and vowels at the end of the search term is wrongly removed. (#29071)
Co-authored-by: sukoom pornsuksiri <sukoom@mm.co.th>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
2e13cbb84d
Коммит
f0280d6dd4
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
var searchTermPuncStart = regexp.MustCompile(`^[^\pL\d\s#"]+`)
|
||||
var searchTermPuncEnd = regexp.MustCompile(`[^\pL\d\s*"]+$`)
|
||||
var searchTermPuncEnd = regexp.MustCompile(`[^\pL\p{M}\d\s*"]+$`)
|
||||
|
||||
type SearchParams struct {
|
||||
Terms string `json:"terms,omitempty"`
|
||||
|
||||
@@ -1011,6 +1011,50 @@ func TestParseSearchFlags2(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "string end with thai upper vowel",
|
||||
Input: "สวัสดี",
|
||||
Words: []searchWord{
|
||||
{
|
||||
value: "สวัสดี",
|
||||
exclude: false,
|
||||
},
|
||||
},
|
||||
Flags: []flag{},
|
||||
},
|
||||
{
|
||||
Name: "string end with thai upper tone mark",
|
||||
Input: "ที่นี่",
|
||||
Words: []searchWord{
|
||||
{
|
||||
value: "ที่นี่",
|
||||
exclude: false,
|
||||
},
|
||||
},
|
||||
Flags: []flag{},
|
||||
},
|
||||
{
|
||||
Name: "string end with thai upper indication mark",
|
||||
Input: "การันต์",
|
||||
Words: []searchWord{
|
||||
{
|
||||
value: "การันต์",
|
||||
exclude: false,
|
||||
},
|
||||
},
|
||||
Flags: []flag{},
|
||||
},
|
||||
{
|
||||
Name: "string end with thai lower vowel",
|
||||
Input: "กตัญญู",
|
||||
Words: []searchWord{
|
||||
{
|
||||
value: "กตัญญู",
|
||||
exclude: false,
|
||||
},
|
||||
},
|
||||
Flags: []flag{},
|
||||
},
|
||||
} {
|
||||
t.Run(testCase.Name, func(t *testing.T) {
|
||||
words, flags := parseSearchFlags(splitWords(testCase.Input))
|
||||
|
||||
@@ -275,9 +275,10 @@ const DEFAULT_OPTIONS: TextFormattingOptions = {
|
||||
* Hangul Compatibility Jamo: \u3130-\u318f
|
||||
* Cyrillic characters: \u0400-\u04ff, \u0500-\u052f
|
||||
* Additional CJK and Hangul compatibility characters: \u2de0-\u2dff
|
||||
* Thai characters: \u0e00-\u0e7f
|
||||
**/
|
||||
// eslint-disable-next-line no-misleading-character-class
|
||||
export const cjkrPattern = /[\u3000-\u303f\u3040-\u309f\u30a0-\u30ff\uff00-\uff9f\u4e00-\u9faf\u3400-\u4dbf\uac00-\ud7a3\u1100-\u11ff\u3130-\u318f\u0400-\u04ff\u0500-\u052f\u2de0-\u2dff]/;
|
||||
export const cjkrPattern = /[\u3000-\u303f\u3040-\u309f\u30a0-\u30ff\uff00-\uff9f\u4e00-\u9faf\u3400-\u4dbf\uac00-\ud7a3\u1100-\u11ff\u3130-\u318f\u0400-\u04ff\u0500-\u052f\u2de0-\u2dff\u0e00-\u0e7f]/;
|
||||
|
||||
export function formatText(
|
||||
text: string,
|
||||
|
||||
@@ -94,6 +94,11 @@ describe('TextFormatting.searchHighlighting', () => {
|
||||
input: 'These are [words in a sentence](https://example.com).',
|
||||
searchMatches: ['example'],
|
||||
expected: '<p>These are <a class="theme markdown__link search-highlight" href="https://example.com" rel="noreferrer" target="_blank">words in a sentence</a>.</p>',
|
||||
}, {
|
||||
name: 'search match thai word',
|
||||
input: 'สวัสดีนี่คือการทดสอบภาษาไทย',
|
||||
searchMatches: ['สวัสดี'],
|
||||
expected: '<p><span class="search-highlight">สวัสดี</span>นี่คือการทดสอบภาษาไทย</p>',
|
||||
}];
|
||||
|
||||
for (const testCase of testCases) {
|
||||
|
||||
Ссылка в новой задаче
Block a user