mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-27 04:32:14 +00:00
Fixed occurances of altered titles in search results
This commit is contained in:
parent
21d3620ef0
commit
fc7bd57dc8
@ -141,11 +141,12 @@ class SearchResultsFormatter
|
|||||||
*/
|
*/
|
||||||
protected function formatTextUsingMatchPositions(array $matchPositions, string $originalText, int $targetLength): string
|
protected function formatTextUsingMatchPositions(array $matchPositions, string $originalText, int $targetLength): string
|
||||||
{
|
{
|
||||||
$contextRange = 32;
|
|
||||||
$maxEnd = strlen($originalText);
|
$maxEnd = strlen($originalText);
|
||||||
$lastEnd = 0;
|
|
||||||
$firstStart = null;
|
|
||||||
$fetchAll = ($targetLength === 0);
|
$fetchAll = ($targetLength === 0);
|
||||||
|
$contextLength = ($fetchAll ? 0 : 32);
|
||||||
|
|
||||||
|
$firstStart = null;
|
||||||
|
$lastEnd = 0;
|
||||||
$content = '';
|
$content = '';
|
||||||
$contentTextLength = 0;
|
$contentTextLength = 0;
|
||||||
|
|
||||||
@ -155,8 +156,8 @@ class SearchResultsFormatter
|
|||||||
|
|
||||||
foreach ($matchPositions as $start => $end) {
|
foreach ($matchPositions as $start => $end) {
|
||||||
// Get our outer text ranges for the added context we want to show upon the result.
|
// Get our outer text ranges for the added context we want to show upon the result.
|
||||||
$contextStart = max($start - $contextRange, 0, $lastEnd);
|
$contextStart = max($start - $contextLength, 0, $lastEnd);
|
||||||
$contextEnd = min($end + $contextRange, $maxEnd);
|
$contextEnd = min($end + $contextLength, $maxEnd);
|
||||||
|
|
||||||
// Adjust the start if we're going to be touching the previous match.
|
// Adjust the start if we're going to be touching the previous match.
|
||||||
$startDiff = $start - $lastEnd;
|
$startDiff = $start - $lastEnd;
|
||||||
|
Loading…
Reference in New Issue
Block a user