* Returns an HTML string with marked text for the matches
(label: string | null)
| 165 | * Returns an HTML string with marked text for the matches |
| 166 | */ |
| 167 | private parseLabelToHtml(label: string | null): string | null { |
| 168 | if (label === null) { |
| 169 | return null; |
| 170 | } |
| 171 | |
| 172 | const parts: Array<{highlight: boolean; text: string}> = []; |
| 173 | while (label.indexOf('<ɵ>') !== -1) { |
| 174 | const beforeMatch = label.substring(0, label.indexOf('<ɵ>')); |
| 175 | const match = label.substring(label.indexOf('<ɵ>') + 3, label.indexOf('</ɵ>')); |
| 176 | parts.push({highlight: false, text: beforeMatch}); |
| 177 | parts.push({highlight: true, text: match}); |
| 178 | label = label.substring(label.indexOf('</ɵ>') + 4); |
| 179 | } |
| 180 | parts.push({highlight: false, text: label}); |
| 181 | |
| 182 | return parts |
| 183 | .map((part) => { |
| 184 | return part.highlight ? `<mark>${part.text}</mark>` : `<span>${part.text}</span>`; |
| 185 | }) |
| 186 | .join(''); |
| 187 | } |
| 188 | |
| 189 | public searchWithQuery(query: string): Promise<SearchResultItem[] | undefined> { |
| 190 | return this.client |
no test coverage detected