Fix search highlighting conflict with jsx code (#1886)

Replaces "<>", "</>" highlighting marks with "<|[[--" and "--]]|>" to avoid conflicts when highlighting jsx code.
This commit is contained in:
Sebastian Sdorra
2021-12-06 16:49:31 +01:00
committed by GitHub
parent e4936260a1
commit ad5bbfeef3
5 changed files with 13 additions and 9 deletions

View File

@@ -52,7 +52,7 @@ class LuceneHighlighterTest {
String[] snippets = highlighter.highlight("content", Indexed.Analyzer.DEFAULT, content);
assertThat(snippets).hasSize(1).allSatisfy(
snippet -> assertThat(snippet).contains("<>Golgafrinchan</>")
snippet -> assertThat(snippet).contains("<|[[--Golgafrinchan--]]|>")
);
}
@@ -64,7 +64,7 @@ class LuceneHighlighterTest {
snippet -> assertThat(snippet.split("\n")).contains(
"\t\t\t\tint neighbors= getNeighbors(above, same, below);",
"\t\t\t\tif(neighbors < 2 || neighbors > 3){",
"\t\t\t\t\tnewGen[row]+= \"_\";//<2 or >3 neighbors -> <>die</>",
"\t\t\t\t\tnewGen[row]+= \"_\";//<2 or >3 neighbors -> <|[[--die--]]|>",
"\t\t\t\t}else if(neighbors == 3){",
"\t\t\t\t\tnewGen[row]+= \"#\";//3 neighbors -> spawn/live"
)
@@ -79,7 +79,7 @@ class LuceneHighlighterTest {
snippet -> assertThat(snippet.split("\n")).contains(
"}) => {",
" const renderIcon = () => {",
" return <>{icon ? <Icon name={icon} color=\"<>inherit</>\" className=\"is-medium pr-1\" /> : null}</>;",
" return <>{icon ? <Icon name={icon} color=\"<|[[--inherit--]]|>\" className=\"is-medium pr-1\" /> : null}</>;",
" };"
)
);

View File

@@ -499,7 +499,7 @@ class LuceneQueryBuilderTest {
JsonNode displayName = fields.get("displayName");
assertThat(displayName.get("highlighted").asBoolean()).isTrue();
assertThat(displayName.get("fragments").get(0).asText()).contains("<>Arthur</>");
assertThat(displayName.get("fragments").get(0).asText()).contains("<|[[--Arthur--]]|>");
}
@Test