mirror of
				https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
				synced 2025-10-29 17:25:32 +00:00 
			
		
		
		
	Added Search Page. Final Version for 1st internal relaese
This commit is contained in:
		| @@ -8,6 +8,10 @@ using WhitespaceFuncList = List<(Func<HaXMLReader.EvArgs.Whitespace, HaWeb.HTMLP | ||||
|  | ||||
|  | ||||
| public class SearchRules { | ||||
|     public static readonly TagFuncList OTagRules = new TagFuncList() { | ||||
|         ( (x, _) => x.Name.ToLower() == "kommentar" || x.Name.ToLower() == "subsection", (_, tag, reader) => reader.State.CurrentIdentifier = tag["id"]), | ||||
|     }; | ||||
|  | ||||
|     public static readonly TextFuncList TextRules = new TextFuncList() { | ||||
|         ( (x, _) => true, (sb, text, reader) => { | ||||
|             var t = text.Value; | ||||
| @@ -18,8 +22,8 @@ public class SearchRules { | ||||
|             if (sb.Length >= sw.Length) { | ||||
|                 if (sb.ToString().ToUpperInvariant().Contains(sw)) { | ||||
|                     if (reader.State.Results == null) | ||||
|                         reader.State.Results = new List<(string Page, string Line)>(); | ||||
|                     reader.State.Results.Add((reader.CurrentPage, reader.CurrentLine)); | ||||
|                         reader.State.Results = new List<(string Page, string Line, string Identifier)>(); | ||||
|                     reader.State.Results.Add((reader.CurrentPage, reader.CurrentLine, reader.State.CurrentIdentifier)); | ||||
|                 } | ||||
|                 sb.Remove(0, sb.Length - sw.Length); | ||||
|             } | ||||
| @@ -36,8 +40,8 @@ public class SearchRules { | ||||
|             if (sb.Length >= sw.Length) { | ||||
|                 if (sb.ToString().Contains(sw)) { | ||||
|                     if (reader.State.Results == null) | ||||
|                         reader.State.Results = new List<(string Page, string Line)>(); | ||||
|                     reader.State.Results.Add((reader.CurrentPage, reader.CurrentLine)); | ||||
|                         reader.State.Results = new List<(string Page, string Line, string Identifier)>(); | ||||
|                     reader.State.Results.Add((reader.CurrentPage, reader.CurrentLine, reader.State.CurrentIdentifier)); | ||||
|                 } | ||||
|                 sb.Remove(0, sb.Length - sw.Length); | ||||
|             } | ||||
|   | ||||
| @@ -3,8 +3,9 @@ using System.Text; | ||||
|  | ||||
| public class SearchState : HaWeb.HTMLParser.IState { | ||||
|     internal string SearchWord; | ||||
|     internal string? CurrentIdentifier; | ||||
|     internal bool Normalize; | ||||
|     internal List<(string Page, string Line)>? Results; | ||||
|     internal List<(string Page, string Line, string Identifier)>? Results; | ||||
|  | ||||
|     public SearchState(string searchword, bool normalize = false) { | ||||
|         Normalize = normalize; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Simon Martens
					Simon Martens