-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
350 changed files
with
1,228 additions
and
2,155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,14 +5,15 @@ | |
// System : Sandcastle Help File Builder | ||
// File : SearchHelp.aspx | ||
// Author : Eric Woodruff ([email protected]) | ||
// Updated : 08/13/2022 | ||
// Note : Copyright 2007-2022, Eric Woodruff, All rights reserved | ||
// Updated : 05/15/2014 | ||
// Note : Copyright 2007-2015, Eric Woodruff, All rights reserved | ||
// Compiler: Microsoft C# | ||
// | ||
// This file contains the code used to search for keywords within the help topics using the full-text index | ||
// files created by the help file builder. | ||
// | ||
// This code is published under the Microsoft Public License (Ms-PL). A copy of the license should be | ||
// distributed with the code and can be found at the project website: https://GitHub.com/EWSoftware/SHFB. This | ||
// distributed with the code. It can also be found at the project website: https://GitHub.com/EWSoftware/SHFB. This | ||
// notice, the author's name, and all copyright notices must remain intact in all applications, documentation, | ||
// and source files. | ||
// | ||
|
@@ -119,7 +120,7 @@ private List<string> ParseKeywords(string keywords) | |
{ | ||
checkWord = word.ToLower(CultureInfo.InvariantCulture); | ||
if(checkWord.Length >= 2 && !Char.IsDigit(checkWord[0]) && !keywordList.Contains(checkWord)) | ||
if(checkWord.Length > 2 && !Char.IsDigit(checkWord[0]) && !keywordList.Contains(checkWord)) | ||
keywordList.Add(checkWord); | ||
} | ||
|
@@ -140,8 +141,7 @@ private string Search(List<string> keywords, List<string> fileInfo, | |
StringBuilder sb = new StringBuilder(10240); | ||
Dictionary<string, List<long>> matches = new Dictionary<string, List<long>>(); | ||
List<long> occurrences; | ||
HashSet<int> matchingFileIndices = new HashSet<int>(); | ||
List<int> occurrenceIndices = new List<int>(); | ||
List<int> matchingFileIndices = new List<int>(), occurrenceIndices = new List<int>(); | ||
List<Ranking> rankings = new List<Ranking>(); | ||
string filename, title; | ||
|
@@ -151,13 +151,7 @@ private string Search(List<string> keywords, List<string> fileInfo, | |
foreach(string word in keywords) | ||
{ | ||
occurrences = new List<long>(); | ||
foreach(KeyValuePair<string, List<long>> kv in wordDictionary) | ||
if(kv.Key.Contains(word)) | ||
occurrences.AddRange(kv.Value); | ||
if(occurrences.Count == 0) | ||
if(!wordDictionary.TryGetValue(word, out occurrences)) | ||
return "<strong>Nothing found</strong>"; | ||
matches.Add(word, occurrences); | ||
|
@@ -170,14 +164,18 @@ private string Search(List<string> keywords, List<string> fileInfo, | |
if(isFirst) | ||
{ | ||
isFirst = false; | ||
matchingFileIndices.UnionWith(occurrenceIndices); | ||
matchingFileIndices.AddRange(occurrenceIndices); | ||
} | ||
else | ||
{ | ||
// After the first match, remove files that do not appear for all found keywords | ||
foreach(int i in matchingFileIndices.ToArray()) | ||
if(!occurrenceIndices.Contains(i)) | ||
matchingFileIndices.Remove(i); | ||
// After the first match, remove files that do not appear for | ||
// all found keywords. | ||
for(idx = 0; idx < matchingFileIndices.Count; idx++) | ||
if(!occurrenceIndices.Contains(matchingFileIndices[idx])) | ||
{ | ||
matchingFileIndices.RemoveAt(idx); | ||
idx--; | ||
} | ||
} | ||
} | ||
|
@@ -220,7 +218,7 @@ private string Search(List<string> keywords, List<string> fileInfo, | |
}); | ||
// Format the file list and return the results | ||
sb.Append("<ol>"); | ||
sb.Append("<ol>"); | ||
foreach(Ranking r in rankings) | ||
sb.AppendFormat("<li><a href=\"{0}\" target=\"_blank\">{1}</a></li>", r.Filename, r.PageTitle); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.